Skip to content

fix: use ns::Name binds the bare name Name in validation (#43) - #44

Merged
Kinflou merged 1 commit into
masterfrom
fix/use-binds-bare-name
Aug 31, 2026
Merged

fix: use ns::Name binds the bare name Name in validation (#43)#44
Kinflou merged 1 commit into
masterfrom
fix/use-binds-bare-name

Conversation

@Kinflou

@Kinflou Kinflou commented Aug 31, 2026

Copy link
Copy Markdown
Member

Fixes the bare-name case of #43.

Before

// api.ids
use types::User

struct Session {
    user: User          // ERR: Unknown type 'User' - did you mean 'str'?
}

Only user: types::User (qualified) resolved. use should bind the trailing segment, Rust-style.

Fix

resolve_use_declaration emits FrozenUnit::Import("types::User", ..) (fully-qualified). Now:

  • SymbolTable::is_imported_bare(name) matches a bare name against the trailing :: segment of any in-scope Import.
  • validate_type checks it after contains.

The qualified form is unchanged (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 Aliasresolve_use_declaration still drops the alias entirely. Left on #43.

Test

tests/package/from_sources.rs::cross_schema_use_resolves_across_the_added_schemas now checks both user: User and user: types::User. Full suite green.

Stacked conceptually on #42 (uses PackageSources as the test harness), which is already merged.

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`.
@Kinflou
Kinflou merged commit 6a4ca9e into master Aug 31, 2026
6 checks passed
@Kinflou
Kinflou deleted the fix/use-binds-bare-name branch August 31, 2026 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant