diff options
author | Richard Eisenberg <rae@richarde.dev> | 2019-06-05 18:02:13 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-06-09 18:43:38 -0400 |
commit | a22e51ea6f7a046c87d57ce30d143eef6abee9ff (patch) | |
tree | e8c7647635bf1a6ac428bfea0e48aab9da50c9fa /testsuite/tests | |
parent | 9d238791862e8b128d397a1c0317986ea82ed000 (diff) | |
download | haskell-a22e51ea6f7a046c87d57ce30d143eef6abee9ff.tar.gz |
Fix #16517 by bumping the TcLevel for method sigs
There were actually two bugs fixed here:
1. candidateQTyVarsOfType needs to be careful that it does not
try to zap metavariables from an outer scope as "naughty"
quantification candidates. This commit adds a simple check
to avoid doing so.
2. We weren't bumping the TcLevel in kcHsKindSig, which was used
only for class method sigs. This mistake led to the acceptance
of
class C a where
meth :: forall k. Proxy (a :: k) -> ()
Note that k is *locally* quantified. This patch fixes the
problem by using tcClassSigType, which correctly bumps the
level. It's a bit inefficient because tcClassSigType does other
work, too, but it would be tedious to repeat much of the code
there with only a few changes. This version works well and is
simple.
And, while updating comments, etc., I noticed that tcRnType was
missing a pushTcLevel, leading to #16767, which this patch also
fixes, by bumping the level. In the refactoring here, I also
use solveEqualities. This initially failed ghci/scripts/T15415,
but that was fixed by teaching solveEqualities to respect
-XPartialTypeSignatures.
This patch also cleans up some Notes around error generation that
came up in conversation.
Test case: typecheck/should_fail/T16517, ghci/scripts/T16767
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/ghci/scripts/T16767.script | 3 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T16767.stdout | 2 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T16517.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T16517.stderr | 6 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/tcfail134.stderr | 3 |
7 files changed, 19 insertions, 2 deletions
diff --git a/testsuite/tests/ghci/scripts/T16767.script b/testsuite/tests/ghci/scripts/T16767.script new file mode 100644 index 0000000000..40d4812fed --- /dev/null +++ b/testsuite/tests/ghci/scripts/T16767.script @@ -0,0 +1,3 @@ +:set -fprint-explicit-foralls -fprint-explicit-kinds -XTypeApplications -XDataKinds +import Data.Proxy +:kind! 'Proxy @_ diff --git a/testsuite/tests/ghci/scripts/T16767.stdout b/testsuite/tests/ghci/scripts/T16767.stdout new file mode 100644 index 0000000000..340ed6ee80 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T16767.stdout @@ -0,0 +1,2 @@ +'Proxy @_ :: forall {k} {_ :: k}. Proxy @{k} _ += 'Proxy @{k} @_ diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index 5dd56ca46c..db619c142b 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -297,3 +297,4 @@ test('T14828', normal, ghci_script, ['T14828.script']) test('T16376', normal, ghci_script, ['T16376.script']) test('T16527', normal, ghci_script, ['T16527.script']) test('T16569', normal, ghci_script, ['T16569.script']) +test('T16767', normal, ghci_script, ['T16767.script']) diff --git a/testsuite/tests/typecheck/should_fail/T16517.hs b/testsuite/tests/typecheck/should_fail/T16517.hs new file mode 100644 index 0000000000..2664a18758 --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16517.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE PolyKinds #-} +module T16517 where + +import Data.Proxy +class C a where m :: Proxy (a :: k) diff --git a/testsuite/tests/typecheck/should_fail/T16517.stderr b/testsuite/tests/typecheck/should_fail/T16517.stderr new file mode 100644 index 0000000000..8d20665afc --- /dev/null +++ b/testsuite/tests/typecheck/should_fail/T16517.stderr @@ -0,0 +1,6 @@ + +T16517.hs:5:29: error: + • Expected kind ‘k’, but ‘a’ has kind ‘k0’ + • In the first argument of ‘Proxy’, namely ‘(a :: k)’ + In the type signature: m :: Proxy (a :: k) + In the class declaration for ‘C’ diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index 9e0ba2e455..5be507edbf 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -517,3 +517,4 @@ test('T16414', normal, compile_fail, ['']) test('T16456', normal, compile_fail, ['-fprint-explicit-foralls']) test('T16627', normal, compile_fail, ['']) test('T502', normal, compile_fail, ['']) +test('T16517', normal, compile_fail, ['']) diff --git a/testsuite/tests/typecheck/should_fail/tcfail134.stderr b/testsuite/tests/typecheck/should_fail/tcfail134.stderr index 8e1170cdfb..46ddc334bc 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail134.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail134.stderr @@ -2,6 +2,5 @@ tcfail134.hs:5:33: error: • Expecting one more argument to ‘XML’ Expected a type, but ‘XML’ has kind ‘* -> Constraint’ - • In the type signature: - toXML :: a -> XML + • In the type signature: toXML :: a -> XML In the class declaration for ‘XML’ |