Simon Jakobi pushed to branch wip/sjakobi/multi-caret at Glasgow Haskell Compiler / GHC
Commits:
3e64cdc7 by Simon Jakobi at 2026-06-08T20:37:14+02:00
WIP: Report related locations textually when carets are off
Related locations were previously visible only as carets. Carets are
optional (-fno-diagnostics-show-caret) and some spans have no source to
display (GHCi input, TH-generated code, or code remapped by a LINE pragma
to a file we can't read), so in those cases the extra locations vanished.
decorateDiagnostic now lists, under an "At:" heading printed between the
message and the caret snippets, every location that is not shown as a
caret -- including the primary span, so the list is a complete set of the
locations involved. Each location is shown either as a caret or in the
"At:" list. getCaretDiagnostics reports which real spans it actually
rendered, so the list covers exactly the spans the carets missed. The
Diagnostic GhciMessage instance now forwards diagnosticRelatedLocations,
which it previously dropped.
Locations are compared and deduped by their real span, which ignores the
BufSpan: a duplicate export's related span often differs from the primary
only in its BufSpan, which would otherwise be listed twice or mistaken for
a location beyond the primary. A list naming only the primary is dropped,
since the message header already states it.
The now-redundant location prose is removed from TcRnBindingNameConflict
("Bound at:") and TcRnDuplicateDecls ("Declared at:"), and
TcRnDuplicateNamedDefaultExport is reworded (its two export items are
always identical). TcRnDuplicateExport is left untouched.
A new test, MultiCaretFallback, exercises a single diagnostic whose
related locations are split between carets and the "At:" fallback.
Co-Authored-By: Claude Opus 4.8
- - - - -
63 changed files:
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Types/Error.hs
- compiler/GHC/Utils/Logger.hs
- ghc/GHCi/UI/Exception.hs
- testsuite/tests/default/T25857.stderr
- testsuite/tests/ghci/scripts/T4127a.stderr
- testsuite/tests/ghci/scripts/ghci048.stderr
- testsuite/tests/haddock/haddock_examples/haddock.Test.stderr
- testsuite/tests/indexed-types/should_fail/SimpleFail6.stderr
- testsuite/tests/indexed-types/should_fail/T16110_Fail1.stderr
- testsuite/tests/mdo/should_fail/mdofail002.stderr
- testsuite/tests/mdo/should_fail/mdofail003.stderr
- testsuite/tests/module/mod128.stderr
- testsuite/tests/module/mod18.stderr
- testsuite/tests/module/mod19.stderr
- testsuite/tests/module/mod20.stderr
- testsuite/tests/module/mod21.stderr
- testsuite/tests/module/mod22.stderr
- testsuite/tests/module/mod23.stderr
- testsuite/tests/module/mod24.stderr
- testsuite/tests/module/mod38.stderr
- testsuite/tests/module/mod66.stderr
- testsuite/tests/overloadedrecflds/should_fail/FieldSelectors.stderr
- testsuite/tests/overloadedrecflds/should_fail/NFSDuplicate.stderr
- testsuite/tests/overloadedrecflds/should_fail/T17965.stderr
- testsuite/tests/overloadedrecflds/should_fail/overloadedrecfldsfail03.stderr
- testsuite/tests/patsyn/should_compile/T11959.stderr
- testsuite/tests/patsyn/should_compile/T9975a.stderr
- testsuite/tests/patsyn/should_fail/T14114.stderr
- testsuite/tests/quasiquotation/qq006/qq006.stderr
- testsuite/tests/rename/should_compile/ExportWarnings6.stderr
- testsuite/tests/rename/should_compile/T23318.stderr
- + testsuite/tests/rename/should_fail/MultiCaretFallback.hs
- + testsuite/tests/rename/should_fail/MultiCaretFallback.stderr
- testsuite/tests/rename/should_fail/T22478b.stderr
- testsuite/tests/rename/should_fail/T7164.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rename/should_fail/rn_dup.stderr
- testsuite/tests/rename/should_fail/rnfail001.stderr
- testsuite/tests/rename/should_fail/rnfail002.stderr
- testsuite/tests/rename/should_fail/rnfail003.stderr
- testsuite/tests/rename/should_fail/rnfail004.stderr
- testsuite/tests/rename/should_fail/rnfail009.stderr
- testsuite/tests/rename/should_fail/rnfail010.stderr
- testsuite/tests/rename/should_fail/rnfail011.stderr
- testsuite/tests/rename/should_fail/rnfail012.stderr
- testsuite/tests/rename/should_fail/rnfail013.stderr
- testsuite/tests/rename/should_fail/rnfail015.stderr
- testsuite/tests/rename/should_fail/rnfail043.stderr
- testsuite/tests/th/T8932.stderr
- testsuite/tests/th/TH_dupdecl.stderr
- testsuite/tests/th/TH_spliceD1.stderr
- testsuite/tests/type-data/should_fail/TDMultiple01.stderr
- testsuite/tests/type-data/should_fail/TDMultiple02.stderr
- testsuite/tests/type-data/should_fail/TDPunning.stderr
- testsuite/tests/typecheck/should_fail/T22560_fail_c.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiAppPat.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearMultiPat.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_NonlinearSinglePat.stderr
- testsuite/tests/typecheck/should_fail/tcfail038.stderr
- testsuite/tests/vdq-rta/should_fail/T22326_fail_nonlinear.stderr
- testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_3.stderr
- testsuite/tests/warnings/should_compile/T25901_exp_dup_wc_4.stderr
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e64cdc7a7912ac931523fd7537d6373...
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/3e64cdc7a7912ac931523fd7537d6373...
You're receiving this email because of your account on gitlab.haskell.org.