Skip to content
  • Simon Peyton Jones's avatar
    Ensure that arity is accurate in back end · 3dcb2a66
    Simon Peyton Jones authored
    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. 
    3dcb2a66