summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2022-04-07 16:40:27 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-04-09 13:04:14 -0400
commit5f8d6e65f3d8268c70d6a8434ba9df03087a22eb (patch)
tree758958a0b09670a22ca81ba007ed4164fee7a1d0 /compiler
parent47d18b0b387fbfe07e1b4fbda578a81a74ab0eeb (diff)
downloadhaskell-5f8d6e65f3d8268c70d6a8434ba9df03087a22eb.tar.gz
Fix missing SymCo in pushCoercionIntoLambda
There was a missing SymCo in pushCoercionIntoLambda. Currently this codepath is only used with rewrite rules, so this bug managed to slip by, but trying to use pushCoercionIntoLambda in other contexts revealed the bug.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/Core/Opt/Arity.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/GHC/Core/Opt/Arity.hs b/compiler/GHC/Core/Opt/Arity.hs
index ab38be413c..6c0729ec5b 100644
--- a/compiler/GHC/Core/Opt/Arity.hs
+++ b/compiler/GHC/Core/Opt/Arity.hs
@@ -1784,7 +1784,11 @@ pushCoercionIntoLambda in_scope x e co
in_scope' = in_scope `extendInScopeSet` x'
subst = extendIdSubst (mkEmptySubst in_scope')
x
- (mkCast (Var x') co1)
+ (mkCast (Var x') (mkSymCo co1))
+ -- We substitute x' for x, except we need to preserve types.
+ -- The types are as follows:
+ -- x :: s1, x' :: t1, co1 :: s1 ~# t1,
+ -- so we extend the substitution with x |-> (x' |> sym co1).
in Just (x', substExpr subst e `mkCast` co2)
| otherwise
= pprTrace "exprIsLambda_maybe: Unexpected lambda in case" (ppr (Lam x e))