[Git][ghc/ghc][wip/structured-ghci-errors] Fix UnknownDiagnostic

Jade (@Jade) gitlab at gitlab.haskell.org
Fri Aug 2 22:07:55 UTC 2024



Jade pushed to branch wip/structured-ghci-errors at Glasgow Haskell Compiler / GHC


Commits:
a1a8a301 by Jade at 2024-08-03T00:07:45+02:00
Fix UnknownDiagnostic

- - - - -


3 changed files:

- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Exception.hs
- testsuite/tests/ghci/scripts/T8113.stdout


Changes:

=====================================
ghc/GHCi/UI.hs
=====================================
@@ -2152,7 +2152,7 @@ doLoad load_type howmuch = do
       hmis <- ifaceCache <$> getGHCiState
       -- If GHCi message gets its own configuration at some stage then this will need to be
       -- modified to 'embedUnknownDiagnostic'.
-      ok <- trySuccess $ GHC.loadWithCache (Just hmis) mkUnknownDiagnostic howmuch
+      ok <- trySuccess $ GHC.loadWithCache (Just hmis) (UnknownDiagnostic fromGhcOpts toGhcHint . GhciGhcMessage) howmuch
       afterLoad ok load_type
       pure ok
 


=====================================
ghc/GHCi/UI/Exception.hs
=====================================
@@ -7,6 +7,8 @@
 module GHCi.UI.Exception
   ( GhciMessage(..)
   , GhciMessageOpts(..)
+  , fromGhcOpts
+  , toGhcHint
   , GhciCommandMessage(..)
   , GHCi
   ) where
@@ -51,6 +53,10 @@ data GhciHint where
   GhciCommandHint :: GhciCommandHint -> GhciHint
   GhciGhcHint     :: GhcHint         -> GhciHint
 
+toGhcHint :: GhciHint -> GhcHint
+toGhcHint (GhciGhcHint h)     = h
+toGhcHint (GhciCommandHint h) = UnknownHint h
+
 instance Outputable GhciHint where
   ppr = \case
     GhciCommandHint hint -> ppr hint
@@ -61,6 +67,9 @@ instance HasDefaultDiagnosticOpts GhciMessageOpts where
     (defaultDiagnosticOpts @GhcMessage)
     (defaultDiagnosticOpts @GhciCommandMessage)
 
+fromGhcOpts :: DiagnosticOpts GhcMessage -> DiagnosticOpts GhciMessage
+fromGhcOpts ghc_opts = defaultOpts { ghcMessageOpts = ghc_opts }
+
 instance Diagnostic GhciMessage where
   type DiagnosticOpts GhciMessage = GhciMessageOpts
   type DiagnosticHint GhciMessage = GhciHint


=====================================
testsuite/tests/ghci/scripts/T8113.stdout
=====================================
@@ -1,11 +1,11 @@
 the following macros are defined:
-type
+  • type
 called :type for "()" (ignoring)
 called :type for "True" (ignoring)
 called :type for "()" (ignoring)
 called :type for "False" (ignoring)
 the following macros are defined:
-type
+  • type
 called :type for "()" (chaining)
 () :: ()
 called :type for "True" (chaining)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a1a8a3010e562c5fd715ff1d7e4fdd278a05b4f1

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/a1a8a3010e562c5fd715ff1d7e4fdd278a05b4f1
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240802/d087912c/attachment-0001.html>


More information about the ghc-commits mailing list