diff options
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/quantified-constraints/all.T | 1 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T20666b.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T20666b.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T22891.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T22891.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T22912.hs | 26 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T22912.stderr | 12 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 3 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T20666.stderr | 36 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T20666a.stderr | 18 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/T6161.stderr | 15 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/all.T | 8 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_fail/tcfail223.stderr | 17 |
13 files changed, 132 insertions, 45 deletions
diff --git a/testsuite/tests/quantified-constraints/all.T b/testsuite/tests/quantified-constraints/all.T index b3d0eb920f..d3bfe6e07e 100644 --- a/testsuite/tests/quantified-constraints/all.T +++ b/testsuite/tests/quantified-constraints/all.T @@ -41,3 +41,4 @@ test('T22216d', normal, compile, ['']) test('T22216e', normal, compile, ['']) test('T22223', normal, compile, ['']) test('T19690', normal, compile_fail, ['']) + diff --git a/testsuite/tests/typecheck/should_compile/T20666b.hs b/testsuite/tests/typecheck/should_compile/T20666b.hs new file mode 100644 index 0000000000..7a655b73c9 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T20666b.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE TypeFamilies #-} + +module T20666b where + +type family F a + +class Eq (F a) => D a +class Eq (F a) => C a + +instance D [a] => C [a] + diff --git a/testsuite/tests/typecheck/should_compile/T20666b.stderr b/testsuite/tests/typecheck/should_compile/T20666b.stderr new file mode 100644 index 0000000000..322c6850ea --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T20666b.stderr @@ -0,0 +1,10 @@ + +T20666b.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Eq (F [a])’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Eq (F [a])’ to the instance context, + even though it seems logically implied by other constraints in the context. diff --git a/testsuite/tests/typecheck/should_compile/T22891.hs b/testsuite/tests/typecheck/should_compile/T22891.hs new file mode 100644 index 0000000000..ad6b473395 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T22891.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE UndecidableInstances #-} + +module T22891 where + +class Foo f + +class Foo f => Bar f g + +instance Bar f f => Bar f (h k) diff --git a/testsuite/tests/typecheck/should_compile/T22891.stderr b/testsuite/tests/typecheck/should_compile/T22891.stderr new file mode 100644 index 0000000000..a0bdc1649b --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T22891.stderr @@ -0,0 +1,10 @@ + +T22891.hs:9:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Foo f’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Foo f’ to the instance context, + even though it seems logically implied by other constraints in the context. diff --git a/testsuite/tests/typecheck/should_compile/T22912.hs b/testsuite/tests/typecheck/should_compile/T22912.hs new file mode 100644 index 0000000000..994a8022ef --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T22912.hs @@ -0,0 +1,26 @@ +{-# LANGUAGE MonoLocalBinds #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE UndecidableInstances #-} +{-# LANGUAGE UndecidableSuperClasses #-} + +module T22912 where + + +class c => Exactly c +instance c => Exactly c +class c => Implies c + +data Dict c = c => Dict + +anythingDict :: forall c. Dict c +anythingDict = go + where + go :: (Exactly (Implies c) => Implies c) => Dict c + go = Dict + +-- This is clearly wrong: we shouldn't be able to produce evidence +-- for any constraint whatsoever! However, GHC can be tricked into +-- producing a bottom dictionary. +-- This test checks that it emits an appropriate warning when doing so, +-- to allow users to adapt their code before we plug the hole completely. diff --git a/testsuite/tests/typecheck/should_compile/T22912.stderr b/testsuite/tests/typecheck/should_compile/T22912.stderr new file mode 100644 index 0000000000..b53614baff --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T22912.stderr @@ -0,0 +1,12 @@ + +T22912.hs:17:16: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Implies c’, + arising from the head of a quantified constraint + arising from a use of ‘go’, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Implies + c’ to the context of the quantified constraint, + even though it seems logically implied by other constraints in the context. diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index 07d39cebd3..ff603bbcf3 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -857,3 +857,6 @@ test('T22647', normal, compile, ['']) test('T19577', normal, compile, ['']) test('T22383', normal, compile, ['']) test('T21501', normal, compile, ['']) +test('T20666b', normal, compile, ['']) +test('T22891', normal, compile, ['']) +test('T22912', normal, compile, ['']) diff --git a/testsuite/tests/typecheck/should_fail/T20666.stderr b/testsuite/tests/typecheck/should_fail/T20666.stderr index bc2aad5497..46d0fafcc4 100644 --- a/testsuite/tests/typecheck/should_fail/T20666.stderr +++ b/testsuite/tests/typecheck/should_fail/T20666.stderr @@ -1,20 +1,20 @@ -T20666.hs:13:10: error: [GHC-39999] - • Could not deduce ‘Show (T c)’ - arising from the superclasses of an instance declaration - from the context: (D d, c ~ S d) - bound by the instance declaration at T20666.hs:13:10-31 - Possible fix: - If the constraint looks soluble from a superclass of the instance context, - read 'Undecidable instances and loopy superclasses' in the user manual - • In the instance declaration for ‘C1 c’ +T20666.hs:13:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Show (T c)’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Show (T c)’ to the instance context, + even though it seems logically implied by other constraints in the context. -T20666.hs:17:10: error: [GHC-39999] - • Could not deduce ‘Show (T c)’ - arising from the superclasses of an instance declaration - from the context: (D d, c ~ S d, c' ~ c) - bound by the instance declaration at T20666.hs:17:10-40 - Possible fix: - If the constraint looks soluble from a superclass of the instance context, - read 'Undecidable instances and loopy superclasses' in the user manual - • In the instance declaration for ‘C2 c'’ +T20666.hs:17:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Show (T c)’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Show (T c)’ to the instance context, + even though it seems logically implied by other constraints in the context. diff --git a/testsuite/tests/typecheck/should_fail/T20666a.stderr b/testsuite/tests/typecheck/should_fail/T20666a.stderr index 4192b88807..bed585dcd2 100644 --- a/testsuite/tests/typecheck/should_fail/T20666a.stderr +++ b/testsuite/tests/typecheck/should_fail/T20666a.stderr @@ -1,10 +1,10 @@ -T20666a.hs:11:10: error: [GHC-39999] - • Could not deduce ‘Eq (F [a])’ - arising from the superclasses of an instance declaration - from the context: D [a] - bound by the instance declaration at T20666a.hs:11:10-23 - Possible fix: - If the constraint looks soluble from a superclass of the instance context, - read 'Undecidable instances and loopy superclasses' in the user manual - • In the instance declaration for ‘C [a]’ +T20666a.hs:11:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Eq (F [a])’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Eq (F [a])’ to the instance context, + even though it seems logically implied by other constraints in the context. diff --git a/testsuite/tests/typecheck/should_fail/T6161.stderr b/testsuite/tests/typecheck/should_fail/T6161.stderr index 71c7455abd..c1daab09df 100644 --- a/testsuite/tests/typecheck/should_fail/T6161.stderr +++ b/testsuite/tests/typecheck/should_fail/T6161.stderr @@ -1,7 +1,10 @@ -T6161.hs:19:10: error: [GHC-39999] - • Could not deduce ‘Super (Fam a)’ - arising from the superclasses of an instance declaration - from the context: Foo a - bound by the instance declaration at T6161.hs:19:10-31 - • In the instance declaration for ‘Duper (Fam a)’ +T6161.hs:19:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Super (Fam a)’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Super (Fam a)’ to the instance context, + even though it seems logically implied by other constraints in the context. diff --git a/testsuite/tests/typecheck/should_fail/all.T b/testsuite/tests/typecheck/should_fail/all.T index a7e9f6a678..f8a3db350c 100644 --- a/testsuite/tests/typecheck/should_fail/all.T +++ b/testsuite/tests/typecheck/should_fail/all.T @@ -241,7 +241,7 @@ test('tcfail215', normal, compile_fail, ['']) test('tcfail216', normal, compile_fail, ['']) test('tcfail217', normal, compile_fail, ['']) test('tcfail218', normal, compile_fail, ['']) -test('tcfail223', normal, compile_fail, ['']) +test('tcfail223', normal, compile, ['']) # To become compile_fail after migration period (see #22912) test('tcfail224', normal, compile_fail, ['']) test('tcfail225', normal, compile_fail, ['']) @@ -294,7 +294,7 @@ test('T19187a', normal, compile_fail, ['']) test('T2534', normal, compile_fail, ['']) test('T7175', normal, compile_fail, ['']) test('T7210', normal, compile_fail, ['']) -test('T6161', normal, compile_fail, ['']) +test('T6161', normal, compile, ['']) # To become compile_fail after migration period (see #22912) test('T7368', normal, compile_fail, ['']) test('T7264', normal, compile_fail, ['']) test('T6069', normal, compile_fail, ['']) @@ -665,5 +665,5 @@ test('T21530a', normal, compile_fail, ['']) test('T21530b', normal, compile_fail, ['']) test('T22570', normal, compile_fail, ['']) test('T22645', normal, compile_fail, ['']) -test('T20666', normal, compile_fail, ['']) -test('T20666a', normal, compile_fail, ['']) +test('T20666', normal, compile, ['']) # To become compile_fail after migration period (see #22912) +test('T20666a', normal, compile, ['']) # To become compile_fail after migration period (see #22912) diff --git a/testsuite/tests/typecheck/should_fail/tcfail223.stderr b/testsuite/tests/typecheck/should_fail/tcfail223.stderr index d3173adde7..8201c8839f 100644 --- a/testsuite/tests/typecheck/should_fail/tcfail223.stderr +++ b/testsuite/tests/typecheck/should_fail/tcfail223.stderr @@ -1,9 +1,10 @@ -tcfail223.hs:10:10: error: [GHC-39999] - • Could not deduce ‘Class1 a’ - arising from the superclasses of an instance declaration - from the context: Class3 a - bound by the instance declaration at tcfail223.hs:10:10-29 - Possible fix: - add (Class1 a) to the context of the instance declaration - • In the instance declaration for ‘Class2 a’ +tcfail223.hs:10:10: warning: [GHC-36038] [-Wloopy-superclass-solve (in -Wdefault)] + I am solving the constraint ‘Class1 a’, + arising from the superclasses of an instance declaration, + in a way that might turn out to loop at runtime. + Future versions of GHC will turn this warning into an error. + See the user manual, § Undecidable instances and loopy superclasses. + Suggested fix: + Add the constraint ‘Class1 a’ to the instance context, + even though it seems logically implied by other constraints in the context. |