From d5254eea37cf82e8f215469e3186cec4069893e1 Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 2 Sep 2002 16:38:24 +0000 Subject: [PATCH] [project @ 2002-09-02 16:38:24 by simonpj] Fix an obscure bug in an optimisation for 'coerce' which wasn't taking account of the possiblity of type arguments. MERGE TO STABLE --- ghc/compiler/simplCore/Simplify.lhs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ghc/compiler/simplCore/Simplify.lhs b/ghc/compiler/simplCore/Simplify.lhs index 0a30390..303fd65 100644 --- a/ghc/compiler/simplCore/Simplify.lhs +++ b/ghc/compiler/simplCore/Simplify.lhs @@ -795,12 +795,14 @@ simplNote env (Coerce to from) body cont -- the inner one is redundant addCoerce t1t2 s1s2 (ApplyTo dup arg arg_se cont) - | Just (s1, s2) <- splitFunTy_maybe s1s2 + | not (isTypeArg arg), -- This whole case only works for value args + -- Could upgrade to have equiv thing for type apps too + Just (s1, s2) <- splitFunTy_maybe s1s2 -- (coerce (T1->T2) (S1->S2) F) E -- ===> -- coerce T2 S2 (F (coerce S1 T1 E)) -- - -- t1t2 must be a function type, T1->T2 + -- t1t2 must be a function type, T1->T2, because it's applied to something -- but s1s2 might conceivably not be -- -- When we build the ApplyTo we can't mix the out-types -- 1.7.10.4