Ensure that arity is accurate in back end
authorsimonpj@microsoft.com <unknown>
Thu, 10 Apr 2008 08:49:30 +0000 (08:49 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 10 Apr 2008 08:49:30 +0000 (08:49 +0000)
commit3dcb2a668e541eb0b04b5d22c2b86b2700766d46
treefbaecb9d78a502c028d6970278eaebfb9d0c2c74
parentf3a381ed3888bf634e91400e52204ab2252567d2
Ensure that arity is accurate in back end

See Note [exprArity invariant] in CoreUtils.  In code generated by Happy
I was seeing this after TidyPgm and CorePrep

f :: Any
f {arity 1} = id `cast` unsafe-co

So f claimed to have arity 1 (because exprArity looked inside), but
did not have any top-level lambdas (because its type is Any).

This triggered a slightly-obscure ASSERT failure in CoreToStg

This patch
- makes exprArity trim the arity if the type is not a function
- adds a stronger ASSERT in TidyPgm

It's not the only way to solve this problem (see Note [exprArity invariant])
but it's enough for now.
compiler/coreSyn/CorePrep.lhs
compiler/coreSyn/CoreUtils.lhs
compiler/stgSyn/CoreToStg.lhs