diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2021-08-25 06:45:27 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-08-25 19:35:12 -0400 |
commit | 0759c069e7cf328c8e397623bb2e5403de52e869 (patch) | |
tree | 311e9631600d3dd221e44897616f60c4497edd36 /testsuite | |
parent | 71e8094d3855d7c3a105ba5655f7995f94b84832 (diff) | |
download | haskell-0759c069e7cf328c8e397623bb2e5403de52e869.tar.gz |
Desugarer: Bring existentials in scope when substituting into record GADTs
This fixes an outright bug in which the desugarer did not bring the
existentially quantified type variables of a record GADT into `in_subst`'s
in-scope set, leading to #20278. It also addresses a minor inefficiency in
which `out_subst` was made into a substitution when a simpler `TvSubstEnv`
would suffice.
Fixes #20278.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/gadt/T20278.hs | 19 | ||||
-rw-r--r-- | testsuite/tests/gadt/all.T | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/testsuite/tests/gadt/T20278.hs b/testsuite/tests/gadt/T20278.hs new file mode 100644 index 0000000000..436ff425cb --- /dev/null +++ b/testsuite/tests/gadt/T20278.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE GADTs #-} +module T20278 where + +import Data.Kind +import GHC.Exts + +type X1 :: TYPE rep -> Type +data X1 a where + MkX1 :: { fld1a :: a, fld1b :: Int } -> X1 a + +upd1 :: forall rep (a :: TYPE rep). X1 a -> X1 a +upd1 x = x { fld1b = 3 } + +type X2 :: Type -> Type +data X2 a where + MkX2 :: { fld2a :: b, fld2b :: Int } -> X2 (Maybe b) + +upd2 :: X2 a -> X2 a +upd2 x = x { fld2b = 3 } diff --git a/testsuite/tests/gadt/all.T b/testsuite/tests/gadt/all.T index 91ba74b722..9179a40288 100644 --- a/testsuite/tests/gadt/all.T +++ b/testsuite/tests/gadt/all.T @@ -120,4 +120,5 @@ test('T15009', normal, compile, ['']) test('T15558', normal, compile, ['']) test('T16427', normal, compile_fail, ['']) test('T18191', normal, compile_fail, ['']) +test('T20278', normal, compile, ['']) test('SynDataRec', normal, compile, ['']) |