Closed michallepicki closed 3 years ago
Describe the bug When function arguments have their types specified in a function definition, the Erlang code produced is not valid. Currently only the function return type can be annotated without breaking.
To Reproduce
main.ml
let print thing = Io.format "~0tp~n" [ thing ]
let add (x : int) (y : int) : int = x + y
let main _ = print (add 1 2)
2. Run command ```bash $ caramel compile main.ml && escript main.erl
Compiling main.erl OK main.erl:11: function x/0 undefined main.erl:11: function y/0 undefined escript: There were compilation errors.
main.erl contains:
main.erl
% Source code generated with Caramel. -module(main). -export([add/2]). -export([main/1]). -export([print/1]). -spec print(_) -> ok. print(Thing) -> io:format(<<"~0tp~n">>, [Thing | []]). -spec add(integer(), integer()) -> integer(). add(_, _) -> erlang:'+'(fun x/0, fun y/0). -spec main(_) -> ok. main(_) -> print(add(1, 2)).
For some reason add arguments are ignored (_) and usages of the arguments are not valid (fun x/0 instead of just X).
add
_
fun x/0
X
Expected behavior
Erlang gets generated the same way as if the user didn't provide type annotations for the arguments:
-spec add(integer(), integer()) -> integer(). add(X, Y) -> erlang:'+'(X, Y).
Environment (please complete the following information):
0.1.0+git-f7b1222
23.2.6
I will look into that, possibly relates to https://github.com/AbstractMachinesLab/caramel/pull/38
Describe the bug When function arguments have their types specified in a function definition, the Erlang code produced is not valid. Currently only the function return type can be annotated without breaking.
To Reproduce
main.ml
containing:let add (x : int) (y : int) : int = x + y
let main _ = print (add 1 2)
main.erl
contains:For some reason
add
arguments are ignored (_
) and usages of the arguments are not valid (fun x/0
instead of justX
).Expected behavior
Erlang gets generated the same way as if the user didn't provide type annotations for the arguments:
Environment (please complete the following information):
0.1.0+git-f7b1222
23.2.6