summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2011-01-05 00:27:12 +0000
committersimonpj@microsoft.com <unknown>2011-01-05 00:27:12 +0000
commit0aebf9c6b0de711b7eefa8c4cdd56d9328886697 (patch)
tree35b42c1e29083918d2e82cacf61d0d41d35385cd /compiler
parente8a42ae2991013f586cb0606fcbd70d9b4c41d6f (diff)
downloadhaskell-0aebf9c6b0de711b7eefa8c4cdd56d9328886697.tar.gz
Fix Trac #4870: get the inlining for an imported INLINABLE Id
We need the unfolding even for a *recursive* function (indeed that's the point) and I was using the wrong function to get it (idUnfolding rather than realIdUnfolding).
Diffstat (limited to 'compiler')
-rw-r--r--compiler/deSugar/DsBinds.lhs13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/deSugar/DsBinds.lhs b/compiler/deSugar/DsBinds.lhs
index 57c7482596..815c0d1cfb 100644
--- a/compiler/deSugar/DsBinds.lhs
+++ b/compiler/deSugar/DsBinds.lhs
@@ -526,13 +526,14 @@ dsSpec mb_poly_rhs (L loc (SpecPrag poly_id spec_co spec_inl))
where
is_local_id = isJust mb_poly_rhs
poly_rhs | Just rhs <- mb_poly_rhs
- = rhs
- | Just unfolding <- maybeUnfoldingTemplate (idUnfolding poly_id)
- = unfolding
+ = rhs -- Local Id; this is its rhs
+ | Just unfolding <- maybeUnfoldingTemplate (realIdUnfolding poly_id)
+ = unfolding -- Imported Id; this is its unfolding
+ -- Use realIdUnfolding so we get the unfolding
+ -- even when it is a loop breaker.
+ -- We want to specialise recursive functions!
| otherwise = pprPanic "dsImpSpecs" (ppr poly_id)
- -- In the Nothing case the specialisation is for an imported Id
- -- whose unfolding gives the RHS to be specialised
- -- The type checker has checked that it has an unfolding
+ -- The type checker has checked that it *has* an unfolding
specUnfolding :: (CoreExpr -> CoreExpr) -> Type
-> Unfolding -> DsM (Unfolding, OrdList (Id,CoreExpr))