Representation-polymorphism checks for primops check too many arguments
The following program is currently rejected:
blart :: forall (r :: RuntimeRep) (a :: TYPE r). a -> a blart = raise# 5
error: Cannot use function with representation-polymorphic arguments: raise# :: Integer -> a -> a (Note that representation-polymorphic primops, such as 'coerce' and unboxed tuples, are eta-expanded internally because they must occur fully saturated. Use -fprint-typechecker-elaboration to display the full expression.) Representation-polymorphic arguments: a :: TYPE r | 13 | blart = raise# 5 | ^^^^^^
The problem is that the code that checks for disallowed representation-polymorphism when instantiating primops, which is supposed to catch cases like:
foo :: forall (r :: RuntimeRep) (a :: TYPE r) b. a -> b foo = unsafeCoerce#
ends up checking all the function arguments in the return type, even past the primop's arity.
I will be fixing this as part of !6164 (closed).