Skip to content

Don't treat trusted import as unknown type when referenced as struct member type#268

Merged
Zuhaitz-dev merged 1 commit intoz-libs:mainfrom
borup3:typecheck-external-c-struct
Mar 2, 2026
Merged

Don't treat trusted import as unknown type when referenced as struct member type#268
Zuhaitz-dev merged 1 commit intoz-libs:mainfrom
borup3:typecheck-external-c-struct

Conversation

@borup3
Copy link
Contributor

@borup3 borup3 commented Mar 1, 2026

Description

Marks trusted imports as external symbols so --typecheck doesn't output Unknown type '%s' (assuming external C struct) when it doesn't have to assume.

This brings the compiler in line with the README during typecheck but with zero warnings:

This treats the header as a module and assumes all symbols accessed through it exist.

I reordered validate_types to avoid searching find_type_alias if it found a struct by that name, and chose to put is_extern_symbol before is_trait as I expect it to be a cheaper search for all projects (like find_selective_import), but as is_trait is more likely to return a match I can swap them back around if desired.

import "raylib.h" as rl;

struct ZImage {
    image: rl::Image;
}

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@github-project-automation github-project-automation bot moved this to Backlog in Zen C kanban Mar 1, 2026
@Zuhaitz-dev Zuhaitz-dev merged commit e9fad04 into z-libs:main Mar 2, 2026
15 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in Zen C kanban Mar 2, 2026
@borup3 borup3 deleted the typecheck-external-c-struct branch March 2, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants