summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorFinley McIlwaine <finleymcilwaine@gmail.com>2022-10-05 09:09:32 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-10-13 06:00:17 -0400
commiteda6c05e65144b35de62c33d0fd5d35a417233ac (patch)
treec8b4b4277240f152a8189e592d9d6923cf3952aa /testsuite/tests
parentbeebf546c9ea818c9d5a61688bfee8f3b7dbeb9f (diff)
downloadhaskell-eda6c05e65144b35de62c33d0fd5d35a417233ac.tar.gz
Clearer error msg for newtype GADTs with defaulted kind
When a newtype introduces GADT eq_specs due to a defaulted RuntimeRep, we detect this and print the error message with explicit kinds. This also refactors newtype type checking to use the new diagnostic infra. Fixes #21447
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/gadt/T14719.stderr5
-rw-r--r--testsuite/tests/indexed-types/should_fail/T14033.stderr5
-rw-r--r--testsuite/tests/indexed-types/should_fail/T2334A.stderr11
-rw-r--r--testsuite/tests/linear/should_fail/LinearGADTNewtype.stderr3
-rw-r--r--testsuite/tests/parser/should_fail/readFail008.stderr9
-rw-r--r--testsuite/tests/polykinds/T11459.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/T15523.stderr5
-rw-r--r--testsuite/tests/typecheck/should_fail/T15796.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/T17955.stderr4
-rw-r--r--testsuite/tests/typecheck/should_fail/T18891a.stderr12
-rw-r--r--testsuite/tests/typecheck/should_fail/T21447.hs8
-rw-r--r--testsuite/tests/typecheck/should_fail/T21447.stderr6
-rw-r--r--testsuite/tests/typecheck/should_fail/all.T1
-rw-r--r--testsuite/tests/typecheck/should_fail/tcfail156.stderr10
14 files changed, 53 insertions, 34 deletions
diff --git a/testsuite/tests/gadt/T14719.stderr b/testsuite/tests/gadt/T14719.stderr
index cfac00c0c0..e71f0e78e5 100644
--- a/testsuite/tests/gadt/T14719.stderr
+++ b/testsuite/tests/gadt/T14719.stderr
@@ -8,9 +8,10 @@ T14719.hs:5:3: error:
5 | MkFoo1 :: Bool
| ^^^^^^^^^^^^^^
-T14719.hs:8:3: error:
- • The constructor of a newtype must have exactly one field
+T14719.hs:8:3: error: [GHC-23517]
+ • A newtype constructor must have exactly one field
but ‘MkFoo2’ has none
+ MkFoo2 :: Foo2
• In the definition of data constructor ‘MkFoo2’
In the newtype declaration for ‘Foo2’
|
diff --git a/testsuite/tests/indexed-types/should_fail/T14033.stderr b/testsuite/tests/indexed-types/should_fail/T14033.stderr
index fbc6b54486..d302c6dfdc 100644
--- a/testsuite/tests/indexed-types/should_fail/T14033.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T14033.stderr
@@ -1,6 +1,7 @@
-T14033.hs:5:16: error:
- • The constructor of a newtype must have exactly one field
+T14033.hs:5:16: error: [GHC-23517]
+ • A newtype constructor must have exactly one field
but ‘Zero’ has none
+ Zero :: Zero
• In the definition of data constructor ‘Zero’
In the newtype declaration for ‘Zero’
diff --git a/testsuite/tests/indexed-types/should_fail/T2334A.stderr b/testsuite/tests/indexed-types/should_fail/T2334A.stderr
index d4cd3285c2..75d33cd3eb 100644
--- a/testsuite/tests/indexed-types/should_fail/T2334A.stderr
+++ b/testsuite/tests/indexed-types/should_fail/T2334A.stderr
@@ -1,13 +1,14 @@
-T2334A.hs:9:26: error:
- • The constructor of a newtype must have exactly one field
- but ‘F’ has two
+T2334A.hs:9:26: error: [GHC-23517]
+ • A newtype constructor must have exactly one field but ‘F’ has two
+ F :: () -> () -> F ()
• In the definition of data constructor ‘F’
In the newtype instance declaration for ‘F’
-T2334A.hs:10:27: error:
- • The constructor of a newtype must have exactly one field
+T2334A.hs:10:27: error: [GHC-23517]
+ • A newtype constructor must have exactly one field
but ‘H’ has none
+ H :: F Int
• In the definition of data constructor ‘H’
In the newtype instance declaration for ‘F’
diff --git a/testsuite/tests/linear/should_fail/LinearGADTNewtype.stderr b/testsuite/tests/linear/should_fail/LinearGADTNewtype.stderr
index 42207d4f72..465476d603 100644
--- a/testsuite/tests/linear/should_fail/LinearGADTNewtype.stderr
+++ b/testsuite/tests/linear/should_fail/LinearGADTNewtype.stderr
@@ -1,5 +1,6 @@
-LinearGADTNewtype.hs:3:4: error:
+LinearGADTNewtype.hs:3:4: error: [GHC-38291]
• A newtype constructor must be linear
+ A :: Int -> A
• In the definition of data constructor ‘A’
In the newtype declaration for ‘A’
diff --git a/testsuite/tests/parser/should_fail/readFail008.stderr b/testsuite/tests/parser/should_fail/readFail008.stderr
index 8fd289a301..e79a4ef8f2 100644
--- a/testsuite/tests/parser/should_fail/readFail008.stderr
+++ b/testsuite/tests/parser/should_fail/readFail008.stderr
@@ -1,6 +1,5 @@
-readFail008.hs:5:15:
- A newtype constructor cannot have a strictness annotation,
- but ‘T’ does
- In the definition of data constructor ‘T’
- In the newtype declaration for ‘N’
+readFail008.hs:5:15: error: [GHC-04049]
+ • A newtype constructor must not have a strictness annotation
+ • In the definition of data constructor ‘T’
+ In the newtype declaration for ‘N’
diff --git a/testsuite/tests/polykinds/T11459.stderr b/testsuite/tests/polykinds/T11459.stderr
index 724395ecd7..ae65ea5613 100644
--- a/testsuite/tests/polykinds/T11459.stderr
+++ b/testsuite/tests/polykinds/T11459.stderr
@@ -1,6 +1,6 @@
-T11459.hs:9:20: error:
- • A newtype constructor cannot have existential type variables
+T11459.hs:9:20: error: [GHC-07525]
+ • A newtype constructor must not have existential type variables
Parser :: forall a {k}.
(forall (f :: k -> *) (r :: k).
Failure f r -> Success a f r -> f r)
diff --git a/testsuite/tests/typecheck/should_fail/T15523.stderr b/testsuite/tests/typecheck/should_fail/T15523.stderr
index 83b7cdbc60..07133257c5 100644
--- a/testsuite/tests/typecheck/should_fail/T15523.stderr
+++ b/testsuite/tests/typecheck/should_fail/T15523.stderr
@@ -1,6 +1,7 @@
-T15523.hs:5:20: error:
- • The constructor of a newtype must have exactly one field
+T15523.hs:5:20: error: [GHC-23517]
+ • A newtype constructor must have exactly one field
but ‘Foo’ has none
+ Foo :: Duration
• In the definition of data constructor ‘Foo’
In the newtype declaration for ‘Duration’
diff --git a/testsuite/tests/typecheck/should_fail/T15796.stderr b/testsuite/tests/typecheck/should_fail/T15796.stderr
index 3aa7ae8d65..81cbc85b63 100644
--- a/testsuite/tests/typecheck/should_fail/T15796.stderr
+++ b/testsuite/tests/typecheck/should_fail/T15796.stderr
@@ -1,6 +1,6 @@
-T15796.hs:6:3: error:
- • A newtype constructor cannot have a context in its type
+T15796.hs:6:3: error: [GHC-17440]
+ • A newtype constructor must not have a context in its type
MkN :: forall a. Show a => a -> N a
• In the definition of data constructor ‘MkN’
In the newtype declaration for ‘N’
diff --git a/testsuite/tests/typecheck/should_fail/T17955.stderr b/testsuite/tests/typecheck/should_fail/T17955.stderr
index 0762facf45..3b5a5b2676 100644
--- a/testsuite/tests/typecheck/should_fail/T17955.stderr
+++ b/testsuite/tests/typecheck/should_fail/T17955.stderr
@@ -1,6 +1,6 @@
-T17955.hs:6:13: error:
- • A newtype constructor cannot have a context in its type
+T17955.hs:6:13: error: [GHC-17440]
+ • A newtype constructor must not have a context in its type
T :: Coercible () T => () -> T
• In the definition of data constructor ‘T’
In the newtype declaration for ‘T’
diff --git a/testsuite/tests/typecheck/should_fail/T18891a.stderr b/testsuite/tests/typecheck/should_fail/T18891a.stderr
index 881924c8a1..a1ef9607bf 100644
--- a/testsuite/tests/typecheck/should_fail/T18891a.stderr
+++ b/testsuite/tests/typecheck/should_fail/T18891a.stderr
@@ -1,12 +1,12 @@
-T18891a.hs:8:4: error:
- • A newtype constructor must have a return type of form T a1 ... an
- MkN1 :: N1 -> N1
+T18891a.hs:8:4: error: [GHC-89498]
+ • A newtype must not be a GADT
+ MkN1 :: N1 @GHC.Types.LiftedRep -> N1 @GHC.Types.LiftedRep
• In the definition of data constructor ‘MkN1’
In the newtype declaration for ‘N1’
-T18891a.hs:12:3: error:
- • A newtype constructor must have a return type of form T a1 ... an
- MkN2 :: N2 -> N2
+T18891a.hs:12:3: error: [GHC-89498]
+ • A newtype must not be a GADT
+ MkN2 :: N2 @GHC.Types.LiftedRep -> N2 @GHC.Types.LiftedRep
• In the definition of data constructor ‘MkN2’
In the newtype declaration for ‘N2’
diff --git a/testsuite/tests/typecheck/should_fail/T21447.hs b/testsuite/tests/typecheck/should_fail/T21447.hs
new file mode 100644
index 0000000000..7a6938d5ad
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T21447.hs
@@ -0,0 +1,8 @@
+module T21447 where
+
+import Data.Kind (Type)
+import GHC.Exts (TYPE)
+
+type H :: TYPE r -> Type
+newtype H a where
+ H :: a -> H a
diff --git a/testsuite/tests/typecheck/should_fail/T21447.stderr b/testsuite/tests/typecheck/should_fail/T21447.stderr
new file mode 100644
index 0000000000..aeba975cba
--- /dev/null
+++ b/testsuite/tests/typecheck/should_fail/T21447.stderr
@@ -0,0 +1,6 @@
+
+T21447.hs:8:3: error: [GHC-89498]
+ • A newtype must not be a GADT
+ H :: forall a. a -> H @GHC.Types.LiftedRep a
+ • In the definition of data constructor ‘H’
+ In the newtype declaration for ‘H’
diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T
index 51d73be7ed..efad13aacd 100644
--- a/testsuite/tests/typecheck/should_fail/all.T
+++ b/testsuite/tests/typecheck/should_fail/all.T
@@ -659,3 +659,4 @@ test('T21338', normal, compile_fail, [''])
test('T21158', normal, compile_fail, [''])
test('T21583', normal, compile_fail, [''])
test('MissingDefaultMethodBinding', normal, compile_fail, [''])
+test('T21447', normal, compile_fail, [''])
diff --git a/testsuite/tests/typecheck/should_fail/tcfail156.stderr b/testsuite/tests/typecheck/should_fail/tcfail156.stderr
index 280f118f90..e50ebcbde4 100644
--- a/testsuite/tests/typecheck/should_fail/tcfail156.stderr
+++ b/testsuite/tests/typecheck/should_fail/tcfail156.stderr
@@ -1,6 +1,6 @@
-tcfail156.hs:7:15:
- A newtype constructor cannot have existential type variables
- Foo :: forall a. a -> Foo
- In the definition of data constructor ‘Foo’
- In the newtype declaration for ‘Foo’
+tcfail156.hs:7:15: error: [GHC-07525]
+ • A newtype constructor must not have existential type variables
+ Foo :: forall a. a -> Foo
+ • In the definition of data constructor ‘Foo’
+ In the newtype declaration for ‘Foo’