Commit 043466b9 authored by Ryan Scott's avatar Ryan Scott Committed by Ben Gamari

Rename the types in a GADT constructor in toposorted order

Previously, we were extracting the free variables from a
GADT constructor in an incorrect order, which caused the type
variables for the constructor's type signature to end up in
non-toposorted order. Thankfully, rearranging the order of types
during renaming makes swift work of this bug.

This fixes a regression introduced in commit
fa29df02.
For whatever reason, that commit also commented out a
significant portion of the `T13123` test. This code appears
to work, so I've opted to uncomment it.

Test Plan: make test TEST=T14808

Reviewers: simonpj, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14808

Differential Revision: https://phabricator.haskell.org/D4413
parent 7f389a58
......@@ -1917,7 +1917,10 @@ rnConDecl decl@(ConDeclGADT { con_names = names
; let explicit_tkvs = hsQTvExplicit qtvs
theta = hsConDeclTheta mcxt
arg_tys = hsConDeclArgTys args
; free_tkvs <- extractHsTysRdrTyVarsDups (res_ty : theta ++ arg_tys)
-- We must ensure that we extract the free tkvs in the
-- order of theta, then arg_tys, then res_ty. Failing to
-- do so resulted in #14808.
; free_tkvs <- extractHsTysRdrTyVarsDups (theta ++ arg_tys ++ [res_ty])
; free_tkvs <- extractHsTvBndrs explicit_tkvs free_tkvs
; let ctxt = ConDeclCtx new_names
......
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeApplications #-}
module T14808 where
import Data.Kind
data ECC ctx f a where
ECC :: ctx => f a -> ECC ctx f a
f :: [()] -> ECC () [] ()
f = ECC @() @[] @()
......@@ -116,3 +116,4 @@ test('T12087', normal, compile_fail, [''])
test('T12468', normal, compile_fail, [''])
test('T14320', normal, compile, [''])
test('T14719', normal, compile_fail, ['-fdiagnostics-show-caret'])
test('T14808', normal, compile, [''])
......@@ -8,7 +8,6 @@ module T13123 where
import GHC.Exts (Constraint)
{-
$([d| idProxy :: forall proxy (a :: k). proxy a -> proxy a
idProxy x = x
|])
......@@ -32,7 +31,6 @@ $([d| class Foo b where
$([d| data GADT where
MkGADT :: forall proxy (a :: k). proxy a -> GADT
|])
-}
$([d| data Dec13 :: (* -> Constraint) -> * where
MkDec13 :: c a => a -> Dec13 c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment