[project @ 2001-10-17 13:12:56 by simonmar]
authorsimonmar <unknown>
Wed, 17 Oct 2001 13:12:56 +0000 (13:12 +0000)
committersimonmar <unknown>
Wed, 17 Oct 2001 13:12:56 +0000 (13:12 +0000)
Use the smart constructor mkNote instead of the dumb constructor
(Note) when rebuilding the expression after eta expansion.  This is
necessary to avoid invalidating some assumptions we make about the
output of etaExpand in CorePrep, in particular that there aren't any
lambda expressions inside an SCC note.

ghc/compiler/coreSyn/CoreUtils.lhs

index 1ca6d37..c8f800f 100644 (file)
@@ -804,14 +804,17 @@ eta_expand n us expr ty
     -- Saturated, so nothing to do
   = expr
 
-       -- Short cut for the case where there already
-       -- is a lambda; no point in gratuitously adding more
 eta_expand n us (Note note@(Coerce _ ty) e) _
   = Note note (eta_expand n us e ty)
 
+       -- Use mkNote so that _scc_s get pushed inside any lambdas that
+       -- are generated as part of the eta expansion.  We rely on this
+       -- behaviour in CorePrep, when we eta expand an already-prepped RHS.
 eta_expand n us (Note note e) ty
-  = Note note (eta_expand n us e ty)
+  = mkNote note (eta_expand n us e ty)
 
+       -- Short cut for the case where there already
+       -- is a lambda; no point in gratuitously adding more
 eta_expand n us (Lam v body) ty
   | isTyVar v
   = Lam v (eta_expand n us body (applyTy ty (mkTyVarTy v)))