diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2022-03-29 10:23:37 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-04-07 12:58:36 -0400 |
commit | 08480d2af91b933a2cfc1e2f97a132eab6bba254 (patch) | |
tree | 7c84f0eb727130598250ef895de8600431f48d1e /testsuite/tests/deriving | |
parent | 02279a9c37deb34556834f706dbedc09258df753 (diff) | |
download | haskell-08480d2af91b933a2cfc1e2f97a132eab6bba254.tar.gz |
Fix the free-var test in validDerivPred
The free-var test (now documented as (VD3)) was too narrow,
affecting only class predicates. #21302 demonstrated that
this wasn't enough!
Fixes #21302.
Co-authored-by: Ryan Scott <ryan.gl.scott@gmail.com>
Diffstat (limited to 'testsuite/tests/deriving')
-rw-r--r-- | testsuite/tests/deriving/should_fail/T21302.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T21302.stderr | 19 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/all.T | 1 |
3 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/tests/deriving/should_fail/T21302.hs b/testsuite/tests/deriving/should_fail/T21302.hs new file mode 100644 index 0000000000..16e7cf320d --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T21302.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE UndecidableInstances, TypeFamilies #-} + +module T21302 where + +data BoxAssocDouble = BoxAssocDouble (BoxAssoc Int) + deriving (Eq) + +type family Assoc a + +data BoxAssoc a = BoxAssoc (Assoc a) + +deriving instance c Eq a => Eq (BoxAssoc a) diff --git a/testsuite/tests/deriving/should_fail/T21302.stderr b/testsuite/tests/deriving/should_fail/T21302.stderr new file mode 100644 index 0000000000..46910cbf4f --- /dev/null +++ b/testsuite/tests/deriving/should_fail/T21302.stderr @@ -0,0 +1,19 @@ + +T21302.hs:6:13: error: + • Could not solve: (c0 Eq Int) + arising from the first field of ‘BoxAssocDouble’ + (type ‘BoxAssoc Int’) + • When deriving the instance for (Eq BoxAssocDouble) + +T21302.hs:12:19: error: + • Could not deduce (c0 Eq a) + from the context: c Eq a + bound by a stand-alone deriving instance declaration: + forall (c :: (* -> Constraint) -> * -> Constraint) a. + c Eq a => + Eq (BoxAssoc a) + at T21302.hs:12:19-43 + • In the ambiguity check for a stand-alone deriving instance declaration + To defer the ambiguity check to use sites, enable AllowAmbiguousTypes + In the stand-alone deriving instance for + ‘c Eq a => Eq (BoxAssoc a)’ diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T index 61d74b72b4..2b2f2af562 100644 --- a/testsuite/tests/deriving/should_fail/all.T +++ b/testsuite/tests/deriving/should_fail/all.T @@ -82,3 +82,4 @@ test('deriving-via-fail4', normal, compile_fail, ['']) test('deriving-via-fail5', normal, compile_fail, ['']) test('T21087', normal, compile_fail, ['']) test('T21087b', [extra_files(['T21087b_aux.hs','T21087b_aux.hs-boot'])], multimod_compile_fail, ['T21087b', '']) +test('T21302', normal, compile_fail, ['']) |