[Git][ghc/ghc][wip/T24448] Error Messages: Improve response for illegal forall and GADT Syntax
Jade (@Jade)
gitlab at gitlab.haskell.org
Tue Feb 20 15:20:24 UTC 2024
Jade pushed to branch wip/T24448 at Glasgow Haskell Compiler / GHC
Commits:
4a55c9b1 by Jade at 2024-02-20T16:16:24+01:00
Error Messages: Improve response for illegal forall and GADT Syntax
forall in a type with -XNoExplicitForAll used to suggest RankNTypes.
In this patch this is changed to the correct ExplicitForAll.
using a where in a data declaration with -XNoGADTSyntax used to suggest GADTs
In this patch this is changed to the correct GADTSyntax.
Fixes: #24448
- - - - -
10 changed files:
- compiler/GHC/Parser/Errors/Ppr.hs
- testsuite/tests/dependent/should_fail/T16326_Fail7.stderr
- testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr
- testsuite/tests/parser/should_fail/T16270.stderr
- testsuite/tests/parser/should_fail/T3095.stderr
- testsuite/tests/parser/should_fail/T8258NoGADTs.stderr
- testsuite/tests/rename/should_fail/rnfail052.stderr
- testsuite/tests/typecheck/should_fail/T3155.stderr
- testsuite/tests/typecheck/should_fail/tcfail166.stderr
- testsuite/tests/typecheck/should_fail/tcfail183.stderr
Changes:
=====================================
compiler/GHC/Parser/Errors/Ppr.hs
=====================================
@@ -674,10 +674,9 @@ instance Diagnostic PsMessage where
PsErrOverloadedRecordDotInvalid{} -> noHints
PsErrIllegalPatSynExport -> [suggestExtension LangExt.PatternSynonyms]
PsErrOverloadedRecordUpdateNoQualifiedFields -> noHints
- PsErrExplicitForall is_unicode ->
- let info = text "or a similar language extension to enable explicit-forall syntax:" <+>
- forallSym is_unicode <+> text "<tvs>. <type>"
- in [ suggestExtensionWithInfo info LangExt.RankNTypes ]
+ PsErrExplicitForall is_unicode -> [useExtensionInOrderTo info LangExt.ExplicitForAll]
+ where info = text "to enable syntax:" <+> forallSym is_unicode <+> user_code "tvs" <> dot <+> user_code "type"
+ user_code = angleBrackets . text
PsErrIllegalQualifiedDo{} -> [suggestExtension LangExt.QualifiedDo]
PsErrQualifiedDoInCmd{} -> noHints
PsErrRecordSyntaxInPatSynDecl{} -> noHints
@@ -732,9 +731,8 @@ instance Diagnostic PsMessage where
PsErrIfInFunAppExpr{} -> suggestParensAndBlockArgs
PsErrProcInFunAppExpr{} -> suggestParensAndBlockArgs
PsErrMalformedTyOrClDecl{} -> noHints
- PsErrIllegalWhereInDataDecl ->
- [ suggestExtensionWithInfo (text "or a similar language extension to enable syntax: data T where")
- LangExt.GADTs ]
+ PsErrIllegalWhereInDataDecl -> [useExtensionInOrderTo info LangExt.GADTSyntax]
+ where info = text "to enable syntax: data T where"
PsErrIllegalDataTypeContext{} -> [suggestExtension LangExt.DatatypeContexts]
PsErrPrimStringInvalidChar -> noHints
PsErrSuffixAT -> noHints
=====================================
testsuite/tests/dependent/should_fail/T16326_Fail7.stderr
=====================================
@@ -2,5 +2,5 @@
T16326_Fail7.hs:9:13: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
=====================================
testsuite/tests/parser/should_fail/ParserNoForallUnicode.stderr
=====================================
@@ -2,5 +2,5 @@
ParserNoForallUnicode.hs:6:8: error: [GHC-25955]
Illegal symbol ‘∀’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: ∀ <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: ∀ <tvs>. <type>
=====================================
testsuite/tests/parser/should_fail/T16270.stderr
=====================================
@@ -36,8 +36,8 @@ T16270.hs:19:5: error: [GHC-65719]
T16270.hs:21:6: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
T16270.hs:22:8: error: [GHC-75254]
Unexpected semi-colons in conditional:
@@ -47,8 +47,8 @@ T16270.hs:22:8: error: [GHC-75254]
T16270.hs:24:10: error: [GHC-36952]
Illegal keyword 'where' in data declaration
Suggested fix:
- Perhaps you intended to use GADTs
- or a similar language extension to enable syntax: data T where
+ Use GADTSyntax
+ to enable syntax: data T where
T16270.hs:26:12: error: [GHC-79767]
Illegal bang-pattern
=====================================
testsuite/tests/parser/should_fail/T3095.stderr
=====================================
@@ -2,8 +2,8 @@
T3095.hs:8:12: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
T3095.hs:8:12: error: [GHC-77878]
Unexpected type ‘forall x. x :: Type’
=====================================
testsuite/tests/parser/should_fail/T8258NoGADTs.stderr
=====================================
@@ -2,5 +2,5 @@
T8258NoGADTs.hs:4:8: error: [GHC-36952]
Illegal keyword 'where' in data declaration
Suggested fix:
- Perhaps you intended to use GADTs
- or a similar language extension to enable syntax: data T where
+ Use GADTSyntax
+ to enable syntax: data T where
=====================================
testsuite/tests/rename/should_fail/rnfail052.stderr
=====================================
@@ -2,17 +2,17 @@
rnfail052.hs:7:6: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
rnfail052.hs:10:14: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
rnfail052.hs:13:15: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
=====================================
testsuite/tests/typecheck/should_fail/T3155.stderr
=====================================
@@ -2,5 +2,5 @@
T3155.hs:14:9: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
=====================================
testsuite/tests/typecheck/should_fail/tcfail166.stderr
=====================================
@@ -2,5 +2,5 @@
tcfail166.hs:6:13: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
=====================================
testsuite/tests/typecheck/should_fail/tcfail183.stderr
=====================================
@@ -2,5 +2,5 @@
tcfail183.hs:5:30: error: [GHC-25955]
Illegal symbol ‘forall’ in type
Suggested fix:
- Perhaps you intended to use RankNTypes
- or a similar language extension to enable explicit-forall syntax: forall <tvs>. <type>
+ Use ExplicitForAll
+ to enable syntax: forall <tvs>. <type>
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4a55c9b129af58f59b29836e66a36e98883b1129
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4a55c9b129af58f59b29836e66a36e98883b1129
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/20240220/7b1e74b0/attachment-0001.html>
More information about the ghc-commits
mailing list