diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2015-06-18 08:54:11 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2015-06-18 08:54:11 +0100 |
commit | 5879d5aab929e9959d48e03dad456b824160b3bf (patch) | |
tree | d9c9d012dc9a06f2e0c77fc487ff5a58a8130df1 /testsuite/tests/polykinds | |
parent | 023a0ba938b69bbb89cb2ce48a07459b07783391 (diff) | |
download | haskell-5879d5aab929e9959d48e03dad456b824160b3bf.tar.gz |
Report arity errors correctly despite kinds
Trac #10516 pointed out that when reporting arity errors
(like "T needs 2 arguments but has been given 1"), we should
not count kind arguments, since they are implicit. If we
include kind args in the count, we get very confusing error
messages indeed.
I did a little bit of refactoring which make some
error messages wobble around. But the payload of
this fix is in TcValidity.tyConArityErr
Diffstat (limited to 'testsuite/tests/polykinds')
-rw-r--r-- | testsuite/tests/polykinds/T10516.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T10516.stderr | 4 | ||||
-rw-r--r-- | testsuite/tests/polykinds/T9222.stderr | 48 | ||||
-rw-r--r-- | testsuite/tests/polykinds/all.T | 1 |
4 files changed, 38 insertions, 24 deletions
diff --git a/testsuite/tests/polykinds/T10516.hs b/testsuite/tests/polykinds/T10516.hs new file mode 100644 index 0000000000..388f3421b8 --- /dev/null +++ b/testsuite/tests/polykinds/T10516.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE PolyKinds #-} +module T10516 where + +type App f a = f a + +newtype X f a = X (f a) + +f :: f a -> X (App f) a +f = X diff --git a/testsuite/tests/polykinds/T10516.stderr b/testsuite/tests/polykinds/T10516.stderr new file mode 100644 index 0000000000..0242722ea5 --- /dev/null +++ b/testsuite/tests/polykinds/T10516.stderr @@ -0,0 +1,4 @@ +
+T10516.hs:8:6: error:
+ The type synonym ‘App’ should have 2 arguments, but has been given 1
+ In the type signature for ‘f’: f :: f a -> X (App f) a
diff --git a/testsuite/tests/polykinds/T9222.stderr b/testsuite/tests/polykinds/T9222.stderr index 01869edd45..1d1a1df779 100644 --- a/testsuite/tests/polykinds/T9222.stderr +++ b/testsuite/tests/polykinds/T9222.stderr @@ -1,24 +1,24 @@ - -T9222.hs:13:3: - Couldn't match type ‘b0’ with ‘b’ - ‘b0’ is untouchable - inside the constraints: a ~ '(b0, c0) - bound by the type of the constructor ‘Want’: - (a ~ '(b0, c0)) => Proxy b0 - at T9222.hs:13:3 - ‘b’ is a rigid type variable bound by - the type of the constructor ‘Want’: - ((a ~ '(b, c)) => Proxy b) -> Want a - at T9222.hs:13:3 - Expected type: '(b, c) - Actual type: a - In the ambiguity check for the type of the constructor ‘Want’: - Want :: forall (k :: BOX) - (k1 :: BOX) - (a :: (,) k k1) - (b :: k) - (c :: k1). - ((a ~ '(b, c)) => Proxy b) -> Want a - To defer the ambiguity check to use sites, enable AllowAmbiguousTypes - In the definition of data constructor ‘Want’ - In the data declaration for ‘Want’ +
+T9222.hs:13:3: error:
+ Couldn't match type ‘b0’ with ‘b’
+ ‘b0’ is untouchable
+ inside the constraints: a ~ '(b0, c0)
+ bound by the type of the constructor ‘Want’:
+ (a ~ '(b0, c0)) => Proxy b0
+ at T9222.hs:13:3
+ ‘b’ is a rigid type variable bound by
+ the type of the constructor ‘Want’:
+ ((a ~ '(b, c)) => Proxy b) -> Want a
+ at T9222.hs:13:3
+ Expected type: '(b, c)
+ Actual type: a
+ In the ambiguity check for the type of the constructor ‘Want’:
+ Want :: forall (k :: BOX)
+ (k1 :: BOX)
+ (a :: (,) k k1)
+ (b :: k)
+ (c :: k1).
+ ((a ~ '(b, c)) => Proxy b) -> Want a
+ To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+ In the definition of data constructor ‘Want’
+ In the data type declaration for ‘Want’
diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index 75d2321aad..76af3ecf00 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -116,3 +116,4 @@ test('T9833', normal, compile, ['']) test('T7908', normal, compile, ['']) test('T10041', normal, compile, ['']) test('T10451', normal, compile_fail, ['']) +test('T10516', normal, compile_fail, ['']) |