Problem
Diagnostics carry exactly one span. Diagnostic and ValidationError both have
a single Span/Pos, so conflict diagnostics — duplicate routes, contract
route conflicts, duplicate endpoints — can only point at one location. They
cannot say "first declared here, also declared here," which is exactly the
information a user needs to resolve a conflict.
This is timely: recent M2 work hardened contract-route conflict validation, and
those messages would be materially clearer with a related location.
Relevant code:
internal/lang/diagnostic.go: Diagnostic (single Pos/Range)
internal/compiler/validate.go: ValidationError (single Span)
internal/compiler/routes.go, route_bindings.go, validate_contract_refs.go:
route / endpoint / contract conflict validators
Scope
Add a related-locations field (e.g. Related []source.NamedSpan) to the
diagnostic contract, thread the first-declaration span through the conflict
validators, and surface related locations in check --json and LSP
relatedInformation.
Acceptance Criteria
- Conflict diagnostics include the primary span plus at least one related span
pointing at the other declaration.
check --json adds related locations additively; existing shape stays
backward compatible.
- LSP maps related locations to
relatedInformation.
- Tests cover duplicate routes and contract route conflicts with two locations.
Verification
go test ./internal/compiler ./internal/lang ./internal/lsp
Problem
Diagnostics carry exactly one span.
DiagnosticandValidationErrorboth havea single
Span/Pos, so conflict diagnostics — duplicate routes, contractroute conflicts, duplicate endpoints — can only point at one location. They
cannot say "first declared here, also declared here," which is exactly the
information a user needs to resolve a conflict.
This is timely: recent M2 work hardened contract-route conflict validation, and
those messages would be materially clearer with a related location.
Relevant code:
internal/lang/diagnostic.go:Diagnostic(singlePos/Range)internal/compiler/validate.go:ValidationError(singleSpan)internal/compiler/routes.go,route_bindings.go,validate_contract_refs.go:route / endpoint / contract conflict validators
Scope
Add a related-locations field (e.g.
Related []source.NamedSpan) to thediagnostic contract, thread the first-declaration span through the conflict
validators, and surface related locations in
check --jsonand LSPrelatedInformation.Acceptance Criteria
pointing at the other declaration.
check --jsonadds related locations additively; existing shape staysbackward compatible.
relatedInformation.Verification
go test ./internal/compiler ./internal/lang ./internal/lsp