I’ve recently been investigating a problem where the bytecode executable was crashing with a segfault. The reason turned out to be that there were
external declarations using the two name form, but with a function having 5 or less arguments.
external foo_ext : int -> int -> int -> int = "foo_ext_bytecode" "foo_ext_native"
where the correct thing to do would be to skip the
"foo_ext_bytecode" since the declared function type has 3 ≤ 5 arguments.
Couldn’t such invalid declarations be rejected by the compiler simply based on the declared argument count?