summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorVladislav Zavialov <vlad.z.4096@gmail.com>2021-06-01 15:46:49 +0300
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-06-02 04:41:08 -0400
commit7d8e1549b908ebb67bfa47d782914fe364e7015d (patch)
tree0679b01524057805873af4a9c3217556bcd024dd /testsuite/tests
parentc5a9e32ee0b372c2a044bce0e9009dcff21ee909 (diff)
downloadhaskell-7d8e1549b908ebb67bfa47d782914fe364e7015d.tar.gz
Disallow linear arrows in GADT records (#19928)
Before this patch, GHC used to silently accept programs such as the following: data R where D1 :: { d1 :: Int } %1 -> R The %1 annotation was completely ignored. Now it is a proper error. One remaining issue is that in the error message (⊸) turns into (%1 ->). This is to be corrected with upcoming exactprint updates.
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/parser/should_fail/T19928.hs8
-rw-r--r--testsuite/tests/parser/should_fail/T19928.stderr12
-rw-r--r--testsuite/tests/parser/should_fail/all.T1
3 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/tests/parser/should_fail/T19928.hs b/testsuite/tests/parser/should_fail/T19928.hs
new file mode 100644
index 0000000000..c6c2947577
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T19928.hs
@@ -0,0 +1,8 @@
+{-# LANGUAGE UnicodeSyntax, LinearTypes #-}
+
+module T19928 where
+
+data R where
+ D1 :: { d1 :: Int } %1 -> R
+ Dp :: { dp :: Int } %p -> R
+ Dl :: { dl :: Int } ⊸ R
diff --git a/testsuite/tests/parser/should_fail/T19928.stderr b/testsuite/tests/parser/should_fail/T19928.stderr
new file mode 100644
index 0000000000..342639a100
--- /dev/null
+++ b/testsuite/tests/parser/should_fail/T19928.stderr
@@ -0,0 +1,12 @@
+
+T19928.hs:6:9: error:
+ Parse error: ‘(%1 ->)’
+ Record constructors in GADTs must use an ordinary, non-linear arrow.
+
+T19928.hs:7:9: error:
+ Parse error: ‘(%p ->)’
+ Record constructors in GADTs must use an ordinary, non-linear arrow.
+
+T19928.hs:8:9: error:
+ Parse error: ‘(%1 ->)’
+ Record constructors in GADTs must use an ordinary, non-linear arrow.
diff --git a/testsuite/tests/parser/should_fail/all.T b/testsuite/tests/parser/should_fail/all.T
index 49a298c93f..9975f6c5d7 100644
--- a/testsuite/tests/parser/should_fail/all.T
+++ b/testsuite/tests/parser/should_fail/all.T
@@ -190,3 +190,4 @@ test('RecordDotSyntaxFail11', normal, compile_fail, [''])
test('RecordDotSyntaxFail12', normal, compile_fail, [''])
test('RecordDotSyntaxFail13', normal, compile_fail, [''])
test('T19504', normal, compile_fail, [''])
+test('T19928', normal, compile_fail, [''])