Convert diagnostics in `GHC.Tc.Module` to proper `TcRnMessage`
Short Summary: Get rid of the usages of TcRnUnknownMessage
in GHC.Tc.Module
. Do so by creating new type constructors for the TcRnMessage
type, specific to the errors you are converting.
Inside Ghc.Tc.Module
we count 2 occurrences of TcRnUnknownMessage
, one for the error message emitted as part of tcRnModule
and one coming from mark_plugin_unsafe
(which is a warning). We would like to replace these with two new type constructors to be added to the TcRnMessage
type, which would give us a precise (and structured) semantic of the diagnostics in question.
What follows is a possible plan of action, to guide the developer working on this:
-
Add two new type constructors to
GHC.Tc.Errors.Types.TcRnMessage
. If possible, try to document these following the schema used for the existing ones. -
This is a good time to
grep
the codebase for the text of the diagnostics, which should hopefully yield a number of test cases. You can later run the testsuite on those tests locally (e.g../hadrian/build test --only=...
), to verify the final output didn't change. Occasionally the final output might change, for example if new hints are added, but it shouldn't be the case for this ticket. -
GHC will now complain that the
instance Diagnostic TcRnMessage
insideGHC.Tc.Errors.Ppr
is not complete. ThediagnosticMessage
,diagnosticReason
anddiagnosticHints
will need to handle the new type constructors. -
Implement
diagnosticMessage
by copying the original textual representation of the diagnostic message from theGHC.Tc.Module
. If the textual representation is using external data (i.e. local binds in theGHC.Tc.Module
) add the necessary type arguments to the constructor to "carry the data over". Again, follow the existing patterns. -
Implement
diagnosticReason
by copying the originalDiagnosticReason
(s) from the originalGHC.Tc.Module
diagnostics. -
Implement
diagnosticHints
by copying, once again, what the original diagnostic inGHC.Tc.Module
is doing. In both cases, none of the diagnostics emitted hints, sonoHints
is enough here.