Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): disable automatic uncurrying #90

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions caramel/compiler/ocaml_to_erlang/typespecs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@ module Fun = struct
let rec mk_type_expr : Types.type_expr -> Erlang.Ast.type_expr =
fun type_expr ->
match type_expr.desc with
| Tarrow (_, _, _, _) -> (
match Uncurry.from_type_expr type_expr with
| `Uncurried (args, return) ->
let args = List.map mk_type_expr args in
let return = mk_type_expr return in
Type.fun_ ~args ~return
| `Not_a_function ->
Format.fprintf Format.std_formatter
"Tried to uncurry a non-function type!\n%!";
Printtyp.type_expr Format.std_formatter type_expr;
Format.fprintf Format.std_formatter "\n%!";
Error.unsupported_feature `Uncurryable_functions)
| Tarrow (_, param, out, _) ->
let args = [ mk_type_expr param ] in
let return = mk_type_expr out in
Type.fun_ ~args ~return
| Tconstr (p, args, _) ->
let name, args = Names.type_name_of_path p ~args in
let args = List.map mk_type_expr args in
Expand Down
6 changes: 3 additions & 3 deletions tests/compiler/expressions.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
-export([f/1]).
-export([g/0]).

-spec f(fun(() -> A)) -> A.
-spec f(fun((ok) -> A)) -> A.
f(G) -> G().

-spec g() -> _.
Expand All @@ -157,7 +157,7 @@
-spec add(integer(), integer()) -> integer().
add(X, Y) -> erlang:'+'(X, Y).

-spec call_op_2(fun((A, B) -> C), A, B) -> C.
-spec call_op_2(fun((A) -> fun((B) -> C)), A, B) -> C.
call_op_2(F, X, Y) -> F(X, Y).

-spec do_add(integer(), integer()) -> integer().
Expand Down Expand Up @@ -197,7 +197,7 @@
D = 4,
erlang:'+'(erlang:'+'(erlang:'+'(A, B), C), D).

-spec let_nested(fun((integer()) -> A), fun(() -> _), fun(() -> _)) -> A.
-spec let_nested(fun((integer()) -> A), fun((ok) -> _), fun((ok) -> _)) -> A.
let_nested(F, G, H) ->
A = begin
G(),
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/functions.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
iff_using_function({false, _, F}) -> F;
iff_using_function({true, F, _}) -> F.

-spec iff_using_if(boolean(), fun(() -> A), fun(() -> A)) -> A.
-spec iff_using_if(boolean(), fun((ok) -> A), fun((ok) -> A)) -> A.
iff_using_if(Cond, T, F) ->
case Cond of
true -> T();
Expand Down