Skip to content

use foo::Bar does not bind the bare name Bar (qualified-only) #43

Description

@Kinflou

Summary

After use foo::Bar, a bare Bar reference does not resolve — validation reports Unknown type 'Bar'. Only the qualified form foo::Bar works. In Rust, use foo::Bar; binds Bar in scope; Comline should match that.

Repro

// src/types.ids
struct User {
    id: u64
}
// src/api.ids
use types::User

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

Works if written user: types::User.

Confirmed across every form — only the qualified reference resolves:

after use types::User (or {User} / * / crate::types::User) user: User user: types::User
resolves?

Where

core/src/schema/ir/compiler/interpreter/incremental.rsresolve_use_declaration emits FrozenUnit::Import("types::User", span) (fully-qualified). The validator (core/src/schema/ir/validation/) then only matches a field type against that qualified string, not against the trailing symbol.

Fix is one of:

  • resolve_use_declaration also records the local binding (bare User -> types::User), and validation consults it; or
  • validation accepts a bare type name that equals the last segment of some in-scope Import (with a collision check).

use foo::Bar as Baz should bind Baz the same way.

Context

Surfaced while adding PackageSources (#42). Not a regression - pre-existing. Doesn't block the playground work (qualified references work).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions