Skip to content

Commit 92d58ee

Browse files
committed
Adjustments to lambda translation.
1 parent 9cdb770 commit 92d58ee

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

compiler/ml/translcore.ml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,11 +699,9 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
699699
match arity with
700700
| Some arity ->
701701
let prim =
702-
match
703-
(Ast_uncurried.type_extract_uncurried_fun
704-
(Ctype.expand_head e.exp_env e.exp_type))
705-
.desc
706-
with
702+
let expanded = Ctype.expand_head e.exp_env e.exp_type in
703+
let extracted = Ast_uncurried.type_extract_uncurried_fun expanded in
704+
match (Btype.repr extracted).desc with
707705
| Tarrow (Nolabel, t, _, _) -> (
708706
match (Ctype.expand_head e.exp_env t).desc with
709707
| Tconstr (Pident {name = "unit"}, [], _) -> Pjs_fn_make_unit
@@ -1052,7 +1050,14 @@ and transl_function loc partial param case =
10521050
c_rhs =
10531051
{
10541052
exp_desc =
1055-
Texp_function {arg_label = _; param = param'; case; partial = partial'};
1053+
Texp_function
1054+
{
1055+
arg_label = _;
1056+
arity = None;
1057+
param = param';
1058+
case;
1059+
partial = partial';
1060+
};
10561061
} as exp;
10571062
}
10581063
when Parmatch.inactive ~partial pat && not (exp |> has_async_attribute) ->

tests/tests/src/class_type_ffi_test.res

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ let off2 = (o, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) =>
3030
o["huge_method"](a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
3131

3232
/* Test [fn_mk] */
33-
let mk_f = () => (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) =>
34-
a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)
33+
let mk_f = () =>
34+
(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12) =>
35+
a0(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12)

tests/tests/src/more_poly_variant_test.res

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
type rec vlist<'a> = [#Nil | #Cons('a, vlist<'a>)]
22

3-
let rec map = (f): (vlist<'a> => vlist<'b>) => x =>
4-
switch x {
5-
| #Nil => #Nil
6-
| #Cons(a, l) => #Cons(f(a), map(f)(l))
7-
}
3+
let rec map = (f): (vlist<'a> => vlist<'b>) =>
4+
x =>
5+
switch x {
6+
| #Nil => #Nil
7+
| #Cons(a, l) => #Cons(f(a), map(f)(l))
8+
}
89

910
let split_cases = x =>
1011
switch x {

tests/tests/src/test_bs_this.res

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ let uux_this: @this ({"length": int}, int, int) => int = @this (o, x, y) => o["l
22

33
let even = @this (o, x) => x + o
44

5-
let bark = () => @this
6-
(o: 'self, x, y) => {
7-
Js.log((o["length"], o["x"], o["y"], x, y))
8-
x + y
9-
}
5+
let bark = () =>
6+
@this
7+
(o: 'self, x, y) => {
8+
Js.log((o["length"], o["x"], o["y"], x, y))
9+
x + y
10+
}
1011

1112
let js_obj: 'self = {
1213
"bark": @this

tests/tests/src/uncurried_default.args.mjs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Generated by ReScript, PLEASE EDIT WITH CARE
22

33

4-
function withOpt(xOpt, y) {
5-
let x = xOpt !== undefined ? xOpt : 1;
6-
return (zOpt, w) => {
7-
let z = zOpt !== undefined ? zOpt : 1;
4+
function withOpt($staropt$star, y) {
5+
return ($staropt$star$1, w) => {
6+
let x = $staropt$star !== undefined ? $staropt$star : 1;
7+
let z = $staropt$star$1 !== undefined ? $staropt$star$1 : 1;
88
return ((x + y | 0) + z | 0) + w | 0;
99
};
1010
}
@@ -53,10 +53,10 @@ let StandardNotation = {
5353
r3: r3
5454
};
5555

56-
function withOpt$1(xOpt, y) {
57-
let x = xOpt !== undefined ? xOpt : 1;
58-
return (zOpt, w) => {
59-
let z = zOpt !== undefined ? zOpt : 1;
56+
function withOpt$1($staropt$star, y) {
57+
return ($staropt$star$1, w) => {
58+
let x = $staropt$star !== undefined ? $staropt$star : 1;
59+
let z = $staropt$star$1 !== undefined ? $staropt$star$1 : 1;
6060
return ((x + y | 0) + z | 0) + w | 0;
6161
};
6262
}

0 commit comments

Comments
 (0)