After the last refactor of the Erlang printer, we no longer look up the arity of a function at print time, and thus the default arity that's set to zero here is always printed out.
So this OCaml:
let f g = g ()
let rec g _ = f g
that should compile to this Erlang:
f(G) -> G().
g(_) -> f(fun g/1).
Compiles instead to this erlang:
f(G) -> G().
g(_) -> f(fun g/0).
Note the arity of g is obviously 1 since it takes one parameter, but the function reference does not have this information anymore.
To fix this we should change the way that function references are being created here and use the identifier found to lookup the arity of the function.
This could be done by:
Adding a Hashtbl.t from function name's to their a copy of the Erlang AST values
Carrying around an assoc. list of the functions that we've transformed so far.
The second approach would be a little cleaner (considering we've gone so far without any mutable state in the translation), and it happily relies on the assumption that every function will be defined before it is used.
After the last refactor of the Erlang printer, we no longer look up the arity of a function at print time, and thus the default arity that's set to zero here is always printed out.
So this OCaml:
that should compile to this Erlang:
Compiles instead to this erlang:
Note the arity of
g
is obviously 1 since it takes one parameter, but the function reference does not have this information anymore.To fix this we should change the way that function references are being created here and use the identifier found to lookup the arity of the function.
This could be done by:
Hashtbl.t
from function name's to their a copy of the Erlang AST valuesThe second approach would be a little cleaner (considering we've gone so far without any mutable state in the translation), and it happily relies on the assumption that every function will be defined before it is used.
The first approach might be easier to hack on.