Commit 722a6584 authored by Richard Eisenberg's avatar Richard Eisenberg
Browse files

Fix #14618 by applying a subst in deeplyInstantiate

Previously, we were inexplicably not applying an instantiating
substitution to arguments in non-prenex types. It's amazing this
has been around for so long! I guess there aren't a lot of non-prenex
types around.

test case: typecheck/should_fail/T14618
parent e19b6464
......@@ -257,8 +257,9 @@ deeply_instantiate :: CtOrigin
deeply_instantiate orig subst ty
| Just (arg_tys, tvs, theta, rho) <- tcDeepSplitSigmaTy_maybe ty
= do { (subst', tvs') <- newMetaTyVarsX subst tvs
; ids1 <- newSysLocalIds (fsLit "di") (substTys subst' arg_tys)
; let theta' = substTheta subst' theta
; let arg_tys' = substTys subst' arg_tys
theta' = substTheta subst' theta
; ids1 <- newSysLocalIds (fsLit "di") arg_tys'
; wrap1 <- instCall orig (mkTyVarTys tvs') theta'
; traceTc "Instantiating (deeply)" (vcat [ text "origin" <+> pprCtOrigin orig
, text "type" <+> ppr ty
......@@ -271,7 +272,7 @@ deeply_instantiate orig subst ty
<.> wrap2
<.> wrap1
<.> mkWpEvVarApps ids1,
mkFunTys arg_tys rho2) }
mkFunTys arg_tys' rho2) }
| otherwise
= do { let ty' = substTy subst ty
......
{-# LANGUAGE RankNTypes #-}
module T14618 where
safeCoerce :: a -> b
safeCoerce = f'
where
f :: d -> forall c. d
f x = x
f' = f
T14618.hs:6:14: error:
• Couldn't match type ‘a’ with ‘b’
‘a’ is a rigid type variable bound by
the type signature for:
safeCoerce :: forall a b. a -> b
at T14618.hs:5:1-20
‘b’ is a rigid type variable bound by
the type signature for:
safeCoerce :: forall a b. a -> b
at T14618.hs:5:1-20
Expected type: a -> b
Actual type: b -> b
• In the expression: f'
In an equation for ‘safeCoerce’:
safeCoerce
= f'
where
f :: d -> forall c. d
f x = x
f' = f
• Relevant bindings include
safeCoerce :: a -> b (bound at T14618.hs:6:1)
......@@ -462,3 +462,4 @@ test('T14325', normal, compile_fail, [''])
test('T14350', normal, compile_fail, [''])
test('T14390', normal, compile_fail, [''])
test('MissingExportList03', normal, compile_fail, [''])
test('T14618', normal, compile_fail, [''])
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