Skip to content

Sema: decl-phase impl-validation errors are emitted twice (every E1102/Copy-impl diagnostic double-renders) #759

Closed

Description

@ehartford

Repro (flip probe, branch 747-flip @ 01c8248; E1102 shape also doubles on the installed main-world compiler)

type Zqx { s: str }
impl Copy for Zqx
fn main:
    print("x")

check renders the SAME diagnostic twice, byte-identical spans:

error: type 'Zqx' cannot implement Copy: field 's' is not Copy
 --> dblrender.w:2:1
error: type 'Zqx' cannot implement Copy: field 's' is not Copy
 --> dblrender.w:2:1
error: check failed during compilation

Same doubling for duplicate implementation of trait for type [E1102] (that shape reproduces on the current installed main-world with too, via the #750 RegexFlags collision repro). Body/expression-level errors (undefined variable, type mismatch in binding) render ONCE — the doubling is specific to the declaration/impl-validation phase, which evidently runs twice and emits both times without dedupe.

Why it matters

Expected

One diagnostic per (message, span), regardless of how many passes the decl phase runs.

Activity

  1. added a commit that references this issue on Aug 9, 2026
  2. ehartford commented on Aug 31, 2026

    @ehartford
    ContributorAuthor

    Fixed: DiagnosticList.emit drops exact duplicates (severity + message + primary span + code). Root cause at the exact line: ComptimeTransform.w builds transform_sema seeded with the shared diags, runs prepare_for_comptime_transform() (declaration collection emits E1102/Copy-impl errors), hands the diags back — then check_module() runs the same collection again on the main sema into the same list. Insert-time dedup fixes the class: the same words at the same node re-derived by a later pass is one diagnostic. Distinct duplicates (two different dup-impl sites) still render individually; full :test green including every expected-error lane.

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