summaryrefslogtreecommitdiff
path: root/compiler/GHC/Tc
diff options
context:
space:
mode:
authorHaskellMouse <rinat.stryungis@serokell.io>2022-05-31 01:27:56 +0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-01-11 13:43:36 -0500
commit300bcc1577772b6e2848c3432efb14d89af2df76 (patch)
tree879613d969a4e270f72a83cdaf29057e05429a48 /compiler/GHC/Tc
parentaed1974e92366ab8e117734f308505684f70cddf (diff)
downloadhaskell-300bcc1577772b6e2848c3432efb14d89af2df76.tar.gz
Parse qualified terms in type signatures
This commit allows qualified terms in type signatures to pass the parser and to be cathced by renamer with more informative error message. Adds a few tests. Fixes #21605
Diffstat (limited to 'compiler/GHC/Tc')
-rw-r--r--compiler/GHC/Tc/Errors/Ppr.hs9
-rw-r--r--compiler/GHC/Tc/Errors/Types.hs1
2 files changed, 10 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs
index 2e17295073..984cf95903 100644
--- a/compiler/GHC/Tc/Errors/Ppr.hs
+++ b/compiler/GHC/Tc/Errors/Ppr.hs
@@ -718,6 +718,11 @@ instance Diagnostic TcRnMessage where
TcRnNotInScope err name imp_errs _
-> mkSimpleDecorated $
pprScopeError name err $$ vcat (map ppr imp_errs)
+ TcRnTermNameInType name _
+ -> mkSimpleDecorated $
+ quotes (ppr name) <+>
+ (text "is a term-level binding") $+$
+ (text " and can not be used at the type level.")
TcRnUntickedPromotedThing thing
-> mkSimpleDecorated $
text "Unticked promoted" <+> what
@@ -1475,6 +1480,8 @@ instance Diagnostic TcRnMessage where
-> ErrorWithoutFlag
TcRnNotInScope {}
-> ErrorWithoutFlag
+ TcRnTermNameInType {}
+ -> ErrorWithoutFlag
TcRnUntickedPromotedThing {}
-> WarningWithFlag Opt_WarnUntickedPromotedConstructors
TcRnIllegalBuiltinSyntax {}
@@ -1878,6 +1885,8 @@ instance Diagnostic TcRnMessage where
-> noHints
TcRnNotInScope err _ _ hints
-> scopeErrorHints err ++ hints
+ TcRnTermNameInType _ hints
+ -> hints
TcRnUntickedPromotedThing thing
-> [SuggestAddTick thing]
TcRnIllegalBuiltinSyntax {}
diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs
index 13bef7b699..65701f9fee 100644
--- a/compiler/GHC/Tc/Errors/Types.hs
+++ b/compiler/GHC/Tc/Errors/Types.hs
@@ -1717,6 +1717,7 @@ data TcRnMessage where
-> [ImportError] -- ^ import errors that are relevant
-> [GhcHint] -- ^ hints, e.g. enable DataKinds to refer to a promoted data constructor
-> TcRnMessage
+ TcRnTermNameInType :: RdrName -> [GhcHint] -> TcRnMessage
{-| TcRnUntickedPromotedThing is a warning (controlled with -Wunticked-promoted-constructors)
that is triggered by an unticked occurrence of a promoted data constructor.