Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/1466b0ca760a18afbcab9c4128f6a05d220a5968 >--------------------------------------------------------------- commit 1466b0ca760a18afbcab9c4128f6a05d220a5968 Author: Simon Peyton Jones <[email protected]> Date: Fri Sep 9 10:04:55 2011 +0100 Obey the exprArity invariants! Fixes Trac #5441 We were giving arity 2 to a function whose type was Int -> Any That contradicts the exprArity invariant (see Note [exprArity invariant] in CoreArity), and in turn led to function whose actually code-generated arity was different that advertised in the interface file. Result: seg-fault city. >--------------------------------------------------------------- compiler/coreSyn/CoreArity.lhs | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/compiler/coreSyn/CoreArity.lhs b/compiler/coreSyn/CoreArity.lhs index 0fa1c38..431508b 100644 --- a/compiler/coreSyn/CoreArity.lhs +++ b/compiler/coreSyn/CoreArity.lhs @@ -535,6 +535,16 @@ type CheapFun = CoreExpr -> Maybe Type -> Bool -- of the expression; Nothing means "don't know" arityType :: CheapFun -> CoreExpr -> ArityType +arityType cheap_fn (Note n e) + | notSccNote n = arityType cheap_fn e +arityType cheap_fn (Cast e co) + = arityType cheap_fn e + `andArityType` ATop (typeArity (pSnd (coercionKind co))) + -- See Note [exprArity invariant]; must be true of + -- arityType too, since that is how we compute the arity + -- of variables, and they in turn affect result of exprArity + -- Trac #5441 is a nice demo + arityType _ (Var v) | Just strict_sig <- idStrictness_maybe v , (ds, res) <- splitStrictSig strict_sig @@ -576,9 +586,6 @@ arityType cheap_fn (Let b e) cheap_bind (Rec prs) = all is_cheap prs is_cheap (b,e) = cheap_fn e (Just (idType b)) -arityType cheap_fn (Note n e) - | notSccNote n = arityType cheap_fn e -arityType cheap_fn (Cast e _) = arityType cheap_fn e arityType _ _ = vanillaArityType \end{code} @@ -617,7 +624,6 @@ to make the types work. exprEtaExpandArity looks through coerces when computing arity; and etaExpand adds the coerces as necessary when actually computing the expansion. - Note [No crap in eta-expanded code] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The eta expander is careful not to introduce "crap". In particular, _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
