Skip to content

Diagnostics: cross-file labels render line:col against the primary file's line table and omit the file name #670

Closed

Description

@ehartford

Spec reference

§9.1 (data-race diagnostics): "The diagnostic for a failed proof must name the construct that introduced concurrency" — the current renderer cannot correctly name a construct that lives in another file.

What happens

Diagnostic.render (src/Diagnostic.w:114) resolves every label's span offset with source.offset_to_location(...) where source is the PRIMARY diagnostic's file. A label whose span.file differs (e.g. E0921's "program may run concurrently here" pointing into the std prelude) is decoded against the wrong line table and printed as = label @L:C with no file name — both the position and the (implied) file are wrong.

Repro

Any E0921 whose concurrency evidence is in another file:

use std.time
var counter: i32 = 0
fn main:
    counter = counter + 1
    let t = sleep(Duration.millis(1))
    let _ = t.await

Current output labels the evidence as = label @8:1 program may run concurrently here (async function call) — line 8 of the 7-line user file; the true target is std/time.w's sleep call site file/line.

Observed cost

During the #489 E0921 debugging, the evidence label @41:8 had to be reverse-engineered by decoding the byte offset against three different primary files' line tables to discover it actually meant lib/std/task.w:27:1. The renderer should have printed that directly.

Expected

Labels resolve lloc against lab.span.file's source and print the file when it differs from the primary, e.g. = label lib/std/task.w@27:1 ....

Activity

  1. ehartford commented on Jul 15, 2026

    @ehartford
    ContributorAuthor

    Fixed in da76b93.

    Diagnostic.render_with_label_sources renders each label against its own file's line table and prints the file when it differs from the primary: = label <path>@<line>:<col> .... The Zcu render path resolves label file ids through source_for_file_id_frontend; same-file labels keep the exact previous format (internals expected-output tests unchanged-green).

    Before/after on the repro class (only async construct is inside an instantiated std combinator body):

    before:  = label @41:8 program may run concurrently here (async function)      // decoded in the wrong file
    after:   = label <embedded-std>/std/task.w@79:17 program may run concurrently here (async function call)
    

    79:17 is exactly the task_cancel_point().await call inside await_all. Pinned by test/compile_errors/err_global_race_crossfile_label.w.

    Gates on da76b93: build 0, FIXPOINT, audit:all violations=0, :test all targets ok, test-green/last-green recorded.

  2. added a commit that references this issue on Jul 15, 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions