Skip to content

Commit 1cb1325

Browse files
dylan-thinnesJaro Reinders
authored and
Jaro Reinders
committed
Add note to withWarnings explaining the current state of things
1 parent 2f83b0b commit 1cb1325

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

ghcide/src/Development/IDE/GHC/Warnings.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@ import Development.IDE.GHC.Error
1515
import Development.IDE.Types.Diagnostics
1616
import Language.LSP.Protocol.Types (type (|?) (..))
1717

18+
{-
19+
NOTE on withWarnings and its dangers
20+
21+
withWarnings collects warnings by registering a custom logger which extracts
22+
the SDocs of those warnings. If you receive warnings this way, you will not
23+
get them in a structured form. In the medium term we'd like to remove all
24+
uses of withWarnings to get structured messages everywhere we can.
25+
26+
For the time being, withWarnings is no longer used for anything in the main
27+
typecheckModule codepath, but it is still used for bytecode/object code
28+
generation, as well as a few other places.
29+
30+
I suspect some of these functions (e.g. codegen) will need deeper changes to
31+
be able to get diagnostics as a list, though I don't have great evidence for
32+
that atm. I haven't taken a look to see if those functions that are wrapped
33+
with this could produce diagnostics another way.
34+
35+
It would be good for someone to take a look. What we've done so far gives us
36+
diagnostics for renaming and typechecking, and doesn't require us to copy
37+
too much code from GHC or make any deeper changes, and lets us get started
38+
with the bulk of the useful plugin work, but it would be good to have all
39+
diagnostics with structure be collected that way.
40+
-}
1841

1942
-- | Take a GHC monadic action (e.g. @typecheckModule pm@ for some
2043
-- parsed module 'pm@') and produce a "decorated" action that will

0 commit comments

Comments
 (0)