diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2021-07-27 20:02:14 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-29 13:15:09 -0400 |
commit | f4aea1a20d522091286ce429b3aae278ee35d75e (patch) | |
tree | 014ed570cd1e86f3904f696303b4021f8ab7f090 /compiler/GHC/Tc/Errors | |
parent | 9b916e81234fa71ffde85d17c7e6d96302518cd7 (diff) | |
download | haskell-f4aea1a20d522091286ce429b3aae278ee35d75e.tar.gz |
Reject pattern synonyms with linear types (#18806)
Diffstat (limited to 'compiler/GHC/Tc/Errors')
-rw-r--r-- | compiler/GHC/Tc/Errors/Ppr.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/Tc/Errors/Types.hs | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/compiler/GHC/Tc/Errors/Ppr.hs b/compiler/GHC/Tc/Errors/Ppr.hs index 73ef9d9470..de04bedfe2 100644 --- a/compiler/GHC/Tc/Errors/Ppr.hs +++ b/compiler/GHC/Tc/Errors/Ppr.hs @@ -73,6 +73,9 @@ instance Diagnostic TcRnMessage where -> mkSimpleDecorated $ hang (text "Illegal pattern synonym declaration for" <+> quotes (ppr rdrname)) 2 (text "Pattern synonym declarations are only valid at top level") + TcRnLinearPatSyn ty + -> mkSimpleDecorated $ + hang (text "Pattern synonyms do not support linear fields (GHC #18806):") 2 (ppr ty) TcRnEmptyRecordUpdate -> mkSimpleDecorated $ text "Empty record update" TcRnIllegalFieldPunning fld @@ -123,6 +126,8 @@ instance Diagnostic TcRnMessage where -> ErrorWithoutFlag TcRnIllegalPatSynDecl{} -> ErrorWithoutFlag + TcRnLinearPatSyn{} + -> ErrorWithoutFlag TcRnEmptyRecordUpdate -> ErrorWithoutFlag TcRnIllegalFieldPunning{} @@ -168,6 +173,8 @@ instance Diagnostic TcRnMessage where -> [SuggestIncreaseSimplifierIterations] TcRnIllegalPatSynDecl{} -> noHints + TcRnLinearPatSyn{} + -> noHints TcRnEmptyRecordUpdate{} -> noHints TcRnIllegalFieldPunning{} diff --git a/compiler/GHC/Tc/Errors/Types.hs b/compiler/GHC/Tc/Errors/Types.hs index 6d133bff61..a82ac7328f 100644 --- a/compiler/GHC/Tc/Errors/Types.hs +++ b/compiler/GHC/Tc/Errors/Types.hs @@ -231,6 +231,15 @@ data TcRnMessage where -} TcRnIllegalPatSynDecl :: !(LIdP GhcPs) -> TcRnMessage + {-| TcRnLinearPatSyn is an error that occurs whenever a pattern + synonym signature uses a field that is not unrestricted. + + Example(s): None + + Test cases: linear/should_fail/LinearPatSyn2 + -} + TcRnLinearPatSyn :: !Type -> TcRnMessage + {-| TcRnEmptyRecordUpdate is an error that occurs whenever a record is updated without specifying any field. |