Skip to content

Uses of a privately imported name are reported a second time #291

Open

Description

@Rigidity

After #278, an import that names a private item reports PrivateSymbol/PrivateType at the import, but doesn't import the item (importing it would be order-dependent; see #289). So each use of the name gets a second error:

import inner::secret;

mod inner {
    fn secret() -> Int { 42 }
}

fn main() -> Int {
    secret()
}
Error: Cannot reference private symbol `secret` in module `inner`
Error: Undeclared symbol `secret`

The second error adds nothing, and there's one for every use. main before #278 also reported the uses (with UnresolvedImport at the import).

One fix: when a named import finds only private items, record the name in the import's scope as blocked, so that resolving it at a use reports nothing more (the way an unresolved name is handled once it's been reported). It must not bind the private item, or #289 comes back. Note that this is only safe once the binding can't change in a later pass, so the blocked name must give way if a public item with that name appears later.

Low priority: the first error is correct and points at the cause.

Activity

  1. added
    enhancementA feature request or improvement to the compiler
    on Nov 14, 2026
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

    enhancementA feature request or improvement to the compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions