Include ResolvedDiagnosticReason in -fdiagnostics-as-json
(for readability, all JSON is given using YAML syntax)
Motivation
-fdiagnostics-as-json
provides GHC diagnostics in a machine readable form.
However, it is currently hard to reproduce the original GHC error/warning message from that.
For example given
version: "1.0"
ghcVersion: ghc-9.10.1
span:
file: Foo.hs
start: {line: 1, column: 18}
end: {line: 1, column: 21}
severity: Error
code: 47854
message: ["`foo' is exported by `foo' and `foo'"]
hints: []
I would like to produce
Foo.hs:1:18: error: [GHC-47854] [-Wduplicate-exports, Werror=duplicate-exports]
‘foo’ is exported by ‘foo’ and ‘foo’
Proposal
Include reason
in the output of -fdiagnostics-as-json
, e.g. for the example from above include
reason: duplicate-exports
Addition to the JSON Schema:
reason:
description: For warnings (and errors that were born as warnings) the name of the warning flag that triggered them
type: string
Note that the type
is string
rather than string | null
. Also note that reason
is not a required field. This keeps existing messages conformant with the revised schema.
Edited by Simon Hengel