[Git][ghc/ghc][master] compiler: add hint to TcRnBadlyStaged message

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Wed Jun 12 07:11:11 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
0e9c4dee by Ryan Hendrickson at 2024-06-12T03:09:53-04:00
compiler: add hint to TcRnBadlyStaged message

- - - - -


3 changed files:

- compiler/GHC/Tc/Errors/Ppr.hs
- testsuite/tests/th/T17820d.stderr
- testsuite/tests/th/T23829_hasty_b.stderr


Changes:

=====================================
compiler/GHC/Tc/Errors/Ppr.hs
=====================================
@@ -1417,9 +1417,16 @@ instance Diagnostic TcRnMessage where
            , interpp'SP errorVars ]
     TcRnBadlyStaged reason bind_lvl use_lvl
       -> mkSimpleDecorated $
-         text "Stage error:" <+> pprStageCheckReason reason <+>
-         hsep [text "is bound at stage" <+> ppr bind_lvl,
-               text "but used at stage" <+> ppr use_lvl]
+         vcat $
+         [ text "Stage error:" <+> pprStageCheckReason reason <+>
+           hsep [text "is bound at stage" <+> ppr bind_lvl,
+                 text "but used at stage" <+> ppr use_lvl]
+         ] ++
+         [ hsep [ text "Hint: quoting" <+> thBrackets (ppUnless (isValName n) "t") (ppr n)
+                , text "or an enclosing expression would allow the quotation to be used in an earlier stage"
+                ]
+         | StageCheckSplice n <- [reason]
+         ]
     TcRnBadlyStagedType name bind_lvl use_lvl
       -> mkSimpleDecorated $
          text "Badly staged type:" <+> ppr name <+>


=====================================
testsuite/tests/th/T17820d.stderr
=====================================
@@ -1,7 +1,8 @@
-
 T17820d.hs:6:38: error: [GHC-28914]
     • Stage error: ‘foo’ is bound at stage 2 but used at stage 1
+      Hint: quoting [| foo |] or an enclosing expression would allow the quotation to be used in an earlier stage
     • In the untyped splice: $(const [| 0 |] foo)
       In the Template Haskell quotation
         [d| data D = MkD {foo :: Int}
             blargh = $(const [| 0 |] foo) |]
+


=====================================
testsuite/tests/th/T23829_hasty_b.stderr
=====================================
@@ -1,6 +1,7 @@
-
 T23829_hasty_b.hs:8:42: error: [GHC-28914]
     • Stage error: ‘ty’ is bound at stage 2 but used at stage 1
+      Hint: quoting [t| ty |] or an enclosing expression would allow the quotation to be used in an earlier stage
     • In the untyped splice: $ty
       In the Template Haskell quotation
         [t| forall (ty :: TypeQ). Proxy $ty |]
+



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/0e9c4deea7411e735e3e0bd6f6726773eca4ab2b
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/20240612/aef29cb7/attachment-0001.html>


More information about the ghc-commits mailing list