Skip to content

Warn when unqualified import is shadowed by top-level definition. #4519

@hayleigh-dot-dev

Description

@hayleigh-dot-dev

Currently, when an unqualified import like import wibble.{wobble} is shadowed by a top-level definition in the module (const wobble, fn wobble(...)) the warning generated on the import says it is unused:

Unused imported value
This imported value is never used.

Technically this is true, but a clearer warning would notify the developer that the imported value can never be used because it is shadowed by a top-level definition:

Unusable imported value
This imported value can never be used as it is shadowed by the wobble function.

This is a clearer message as the developer may look at their source code and be confused to see wobble is indeed used even though the compiler is warning them otherwise.

// The compiler will warn that `wobble` here is unused...
import wibble.{wobble}

fn something_else(...) {
  // ...but a developer might be confused to see that wobble
  // is used here.
  let x = wobble(...)
  //

  ...
}

// The actual wobble being used is this one
fn wobble(...) {
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions