Skip to content

fix: print diagnostics in source order with the lines of a var file - #69

Merged
wilhelm-murdoch merged 1 commit into
mainfrom
fix/diagnostic-order-and-sources
Oct 3, 2026
Merged

wilhelm-murdoch merged 1 commit into
mainfrom
fix/diagnostic-order-and-sources

Conversation

@wilhelm-murdoch

Copy link
Copy Markdown
Owner

Two problems made diagnostics harder to read:

  • format --validate and up printed several errors in a different order from run to run. The decoder walks a map, and Go randomises the order of a map.
  • A diagnostic about a --var-file showed "(source code not available)" in place of the line, because the diagnostics writer knew only the source of the profile.

Fixes

  • DiagnosticsManager.Write sorts the diagnostics before it writes them. First come those without a place, then those of the profile, then those of each other file by name. Each file goes from top to bottom. The sort is stable, so two diagnostics at the same place keep their order.
  • Write reads the source of each regular file that a diagnostic points into and that the writer does not know yet, for example a --var-file. The writer and the manager share the map of sources, so the writer shows the line. Write never reads a pipe, because a second read of --var-file <(...) can block.
  • format --validate shows its warnings through Report, not through the writer directly, so warnings are sorted too.

@wilhelm-murdoch
wilhelm-murdoch merged commit 0cfe68a into main Oct 3, 2026
14 checks passed
@wilhelm-murdoch
wilhelm-murdoch deleted the fix/diagnostic-order-and-sources branch October 3, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant