stedolan / malfunction

Malfunctional Programming
Other
336 stars 19 forks source link

Runtime-error when trying to apply a non-function #12

Closed fredefox closed 5 years ago

fredefox commented 7 years ago

The error message when you try to apply a value that is not a function could be more helpful. As a minimal example when I try to compile this file:

(module
  ($f 0)
  (_ (apply $f))
  (export)
)

I get the error:

Fatal error: exception File "asmcomp/compilenv.ml", line 336, characters 2-8: Assertion failed
stedolan commented 7 years ago

Functions in OCaml / Malfunction are curried, so a 0-argument function doesn't really make sense (it would just be a value). I'm not sure the extent to which they work internally in OCaml, but they certainly shouldn't cause assertion failures deep in asmcomp.

I'm not sure yet whether the fix is to improve support for 0-argument functions, or just to disallow the (apply $f) syntax entirely.

stedolan commented 5 years ago

b2802dbd88210f76f994d8ee11662501a21a81a0 gives this a better error message.