diff options
author | CarrieMY <carrie.xmy@gmail.com> | 2021-11-19 23:33:34 +0800 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-25 01:05:11 -0500 |
commit | 7c65687e5b14eb2f496c25198ddf761546bc4675 (patch) | |
tree | c9f2e6b5247b57489130eb4ae472fb5e4d3d737c | |
parent | 3639ad8ffbf0bfc2cb600ba138d6bfda2ccd29fe (diff) | |
download | haskell-7c65687e5b14eb2f496c25198ddf761546bc4675.tar.gz |
Enable UnboxedTuples in `genInst`, Fixes #20524
-rw-r--r-- | compiler/GHC/Tc/Deriv.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_compile/T15073.hs (renamed from testsuite/tests/deriving/should_fail/T15073.hs) | 0 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_compile/T15073a.hs (renamed from testsuite/tests/deriving/should_fail/T15073a.hs) | 0 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_compile/all.T | 2 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/T15073.stderr | 9 | ||||
-rw-r--r-- | testsuite/tests/deriving/should_fail/all.T | 2 | ||||
-rw-r--r-- | testsuite/tests/typecheck/T20524/T20524.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/typecheck/T20524/UT.hs | 15 | ||||
-rw-r--r-- | testsuite/tests/typecheck/T20524/all.T | 1 |
9 files changed, 32 insertions, 11 deletions
diff --git a/compiler/GHC/Tc/Deriv.hs b/compiler/GHC/Tc/Deriv.hs index bf95f5c58f..e1a688cd55 100644 --- a/compiler/GHC/Tc/Deriv.hs +++ b/compiler/GHC/Tc/Deriv.hs @@ -1850,6 +1850,9 @@ genInst spec@(DS { ds_tvs = tvs, ds_mechanism = mechanism -- that bring type variables into scope. -- See Note [Newtype-deriving instances] in GHC.Tc.Deriv.Generate , LangExt.InstanceSigs + -- Skip unboxed tuples checking for derived instances when imported + -- in a different module, see #20524 + , LangExt.UnboxedTuples ] | otherwise = [] diff --git a/testsuite/tests/deriving/should_fail/T15073.hs b/testsuite/tests/deriving/should_compile/T15073.hs index b1da4bb701..b1da4bb701 100644 --- a/testsuite/tests/deriving/should_fail/T15073.hs +++ b/testsuite/tests/deriving/should_compile/T15073.hs diff --git a/testsuite/tests/deriving/should_fail/T15073a.hs b/testsuite/tests/deriving/should_compile/T15073a.hs index 87e7571f50..87e7571f50 100644 --- a/testsuite/tests/deriving/should_fail/T15073a.hs +++ b/testsuite/tests/deriving/should_compile/T15073a.hs diff --git a/testsuite/tests/deriving/should_compile/all.T b/testsuite/tests/deriving/should_compile/all.T index e2680a8f9d..64925923ba 100644 --- a/testsuite/tests/deriving/should_compile/all.T +++ b/testsuite/tests/deriving/should_compile/all.T @@ -113,6 +113,8 @@ test('T14682', normal, compile, ['-ddump-deriv -dsuppress-uniques']) test('T14883', normal, compile, ['']) test('T14932', normal, compile, ['']) test('T14933', normal, compile, ['']) +test('T15073', [extra_files(['T15073a.hs'])], multimod_compile, + ['T15073', '-v0']) test('T15290c', normal, compile, ['']) test('T15290d', normal, compile, ['']) test('T15398', normal, compile, ['']) diff --git a/testsuite/tests/deriving/should_fail/T15073.stderr b/testsuite/tests/deriving/should_fail/T15073.stderr deleted file mode 100644 index 79d3a10cdc..0000000000 --- a/testsuite/tests/deriving/should_fail/T15073.stderr +++ /dev/null @@ -1,9 +0,0 @@ - -T15073.hs:8:12: error: - • Illegal unboxed tuple type as function argument: (# Foo a #) - • In the type signature: p :: Foo a -> (# Foo a #) - When typechecking the code for ‘p’ - in a derived instance for ‘P (Foo a)’: - To see the code I am typechecking, use -ddump-deriv - In the instance declaration for ‘P (Foo a)’ - Suggested fix: Perhaps you intended to use UnboxedTuples
\ No newline at end of file diff --git a/testsuite/tests/deriving/should_fail/all.T b/testsuite/tests/deriving/should_fail/all.T index 4743d3530d..70bd0f9dbe 100644 --- a/testsuite/tests/deriving/should_fail/all.T +++ b/testsuite/tests/deriving/should_fail/all.T @@ -72,8 +72,6 @@ test('T14365', [extra_files(['T14365B.hs','T14365B.hs-boot'])], test('T14728a', normal, compile_fail, ['']) test('T14728b', normal, compile_fail, ['']) test('T14916', normal, compile_fail, ['']) -test('T15073', [extra_files(['T15073a.hs'])], multimod_compile_fail, - ['T15073', '-v0']) test('T16181', normal, compile_fail, ['']) test('T16923', normal, compile_fail, ['']) test('T18127b', normal, compile_fail, ['']) diff --git a/testsuite/tests/typecheck/T20524/T20524.hs b/testsuite/tests/typecheck/T20524/T20524.hs new file mode 100644 index 0000000000..4313acbcef --- /dev/null +++ b/testsuite/tests/typecheck/T20524/T20524.hs @@ -0,0 +1,11 @@ +{-#LANGUAGE DerivingVia, GeneralizedNewtypeDeriving#-} + +module T20524 where +import UT + +data Foo = Foo + deriving Tupleable via Boring Foo + +newtype Bar a = Bar () + deriving newtype Tupleable + diff --git a/testsuite/tests/typecheck/T20524/UT.hs b/testsuite/tests/typecheck/T20524/UT.hs new file mode 100644 index 0000000000..2293f5c006 --- /dev/null +++ b/testsuite/tests/typecheck/T20524/UT.hs @@ -0,0 +1,15 @@ +{-#LANGUAGE UnboxedTuples#-} + +module UT where + +class Tupleable a where + tup :: a -> (# a #) + +newtype Boring a = Boring a +instance Tupleable (Boring a) where + tup a = (# a #) + +instance Tupleable () where + tup _ = (# () #) + + diff --git a/testsuite/tests/typecheck/T20524/all.T b/testsuite/tests/typecheck/T20524/all.T new file mode 100644 index 0000000000..e0b595d550 --- /dev/null +++ b/testsuite/tests/typecheck/T20524/all.T @@ -0,0 +1 @@ +test('T20524', [extra_files(['UT.hs'])], multi_compile, ['T20524', [('UT.hs', '')], '-v0']) |