fix: use ns::Name binds the bare name Name in validation (#43) - #44
Merged
Conversation
After `use types::User`, a field `user: User` reported "Unknown type
'User'" — only the qualified `user: types::User` resolved. `use` should
bind the trailing segment, Rust-style.
`resolve_use_declaration` emits `FrozenUnit::Import("types::User", ..)`
(fully-qualified). `SymbolTable::is_imported_bare(name)` now also matches
a bare `name` against the trailing `::` segment of any in-scope `Import`,
and `validate_type` consults it after `contains`. The qualified form is
unchanged (it resolves through `contains`); glob (`use ns::*`) and
whole-namespace (`use ns`) imports already expand to one
`Import("ns::Sym")` per symbol, so they bind too.
Not covered: `use ns::Name as Alias` — `resolve_use_declaration` still
drops the alias. Tracked in #43.
Test: `cross_schema_use_resolves_across_the_added_schemas` now checks both
`user: User` and `user: types::User`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the bare-name case of #43.
Before
Only
user: types::User(qualified) resolved.useshould bind the trailing segment, Rust-style.Fix
resolve_use_declarationemitsFrozenUnit::Import("types::User", ..)(fully-qualified). Now:SymbolTable::is_imported_bare(name)matches a barenameagainst the trailing::segment of any in-scopeImport.validate_typechecks it aftercontains.The qualified form is unchanged (resolves through
contains). Glob (use ns::*) and whole-namespace (use ns) imports already expand to oneImport("ns::Sym")per symbol, so they bind too.Not covered
use ns::Name as Alias—resolve_use_declarationstill drops the alias entirely. Left on #43.Test
tests/package/from_sources.rs::cross_schema_use_resolves_across_the_added_schemasnow checks bothuser: Useranduser: types::User. Full suite green.Stacked conceptually on #42 (uses
PackageSourcesas the test harness), which is already merged.