From f08a180a2923d58a6123deeafc0b319a26687c5b Mon Sep 17 00:00:00 2001 From: simonpj Date: Mon, 4 Jun 2001 16:49:15 +0000 Subject: [PATCH] [project @ 2001-06-04 16:49:15 by simonpj] ---------------------------------- Make exprArity give the right answer ---------------------------------- MERGE INTO 5.00.2 This fixes a fairly long-standing bug in exprArity, dating from the time we allowed arguments to be non-atoms. If f had arity 2, it was saying that f (factorial x) had arity 2, as well, which is plain wrong. --- ghc/compiler/coreSyn/CoreUtils.lhs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ghc/compiler/coreSyn/CoreUtils.lhs b/ghc/compiler/coreSyn/CoreUtils.lhs index e16847f..f7130eb 100644 --- a/ghc/compiler/coreSyn/CoreUtils.lhs +++ b/ghc/compiler/coreSyn/CoreUtils.lhs @@ -791,13 +791,15 @@ And in any case it seems more robust to have exprArity be a bit more intelligent exprArity :: CoreExpr -> Int exprArity e = go e `max` 0 where - go (Lam x e) | isId x = go e + 1 - | otherwise = go e - go (Note _ e) = go e - go (App e (Type t)) = go e - go (App f a) = go f - 1 - go (Var v) = idArity v - go _ = 0 + go (Lam x e) | isId x = go e + 1 + | otherwise = go e + go (Note _ e) = go e + go (App e (Type t)) = go e + go (App f a) | exprIsCheap a = go f - 1 + -- Important! f (fac x) does not have arity 2, + -- even if f does! + go (Var v) = idArity v + go _ = 0 \end{code} -- 1.7.10.4