Skip to content

Show both declaration locations when reporting duplicate names #995

Closed

Description

@LunaStev

Motivation

Duplicate-name errors identify the name but provide no related location for the earlier declaration. Some aggregate-member conflicts highlight the aggregate name instead of the duplicate member, making larger modules harder to repair.

Starting points: semantic declaration validation, semantic program collection, and the existing SourceSpan/related diagnostic contract. Related umbrella #346; #732 addressed malformed struct-field syntax, not duplicate-declaration provenance.

Evidence

Audited canonical master 540728c2eb6cc12f5c69c3fb3fdb96e07ba059a4 on Linux amd64 with a checkout-built Wave 0.0.1-alpha-dev, matching checkout std, Rust 1.89.0 and LLVM 21.1.8. Executed check and IR-build JSON diagnostics:

struct S { x: i32; x: i64; }
fun main() {}

Reports duplicate field x in struct S at line 1 column 8 (the S), with an empty related array. Likewise fun f() {} fun f() {} fun main() {} identifies the second function but supplies no first-definition note. A local duplicate variable also has no previous-definition location.

Scope

Retain declaration identities/spans so duplicate functions, same-scope variables and aggregate members can point at the repeated name and add the original location as a related label. Preserve existing duplicate rejection, shadowing rules, deterministic ordering, codes and JSON schema. Do not redesign name resolution or expand umbrella #346 into an unbounded migration.

Completion criteria

  • The primary span selects the repeated declaration/member name, including multiline and Unicode fixtures.
  • A related label points to the first conflicting declaration when its source is available.
  • Human and JSON diagnostics agree, while legal nested-scope shadowing remains accepted.

Activity

  1. added
    enhancement
    help wanted
    on Oct 24, 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

    enhancementhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions