Skip to content

Commit b6753da

Browse files
authored
Spring cleaning: remove uncurried arity 0. (rescript-lang#6118)
Uncurried arity 0 does not exist in .res. It was only used in certain internal .ml files.
1 parent 9c378e8 commit b6753da

24 files changed

+1440
-1278
lines changed

jscomp/frontend/ast_core_type.ml

+1-7
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,12 @@ let rec get_uncurry_arity_aux (ty : t) acc =
115115
| _ -> acc
116116

117117
(**
118-
{[ unit -> 'b ]} return arity 0
118+
{[ unit -> 'b ]} return arity 1
119119
{[ unit -> 'a1 -> a2']} arity 2
120120
{[ 'a1 -> 'a2 -> ... 'aN -> 'b ]} return arity N
121121
*)
122122
let get_uncurry_arity (ty : t) =
123123
match ty.ptyp_desc with
124-
| Ptyp_arrow
125-
(Nolabel, { ptyp_desc = Ptyp_constr ({ txt = Lident "unit" }, []) }, rest)
126-
-> (
127-
match rest with
128-
| { ptyp_desc = Ptyp_arrow _ } -> Some (get_uncurry_arity_aux rest 1)
129-
| _ -> Some 0)
130124
| Ptyp_arrow (_, _, rest) -> Some (get_uncurry_arity_aux rest 1)
131125
| _ -> None
132126

jscomp/frontend/ast_uncurry_gen.ml

+1-6
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ let to_uncurry_fn (e : Parsetree.expression) (self : Bs_ast_mapper.mapper)
9191
in
9292
let body = Ast_async.add_async_attribute ~async body in
9393

94-
let len = List.length rev_extra_args in
95-
let arity =
96-
match rev_extra_args with
97-
| [ (_, p) ] -> Ast_pat.is_unit_cont ~yes:0 ~no:len p
98-
| _ -> len
99-
in
94+
let arity = List.length rev_extra_args in
10095
Bs_syntaxerr.err_large_arity loc arity;
10196
let fun_exp = Ast_uncurried.uncurriedFun ~loc ~arity body in
10297
{

jscomp/test/UncurriedExternals.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function tsiU(c) {
4747
});
4848
}
4949

50-
var match = React.useState(function () {
50+
var match = React.useState(function (param) {
5151
return 3;
5252
});
5353

jscomp/test/attr_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function max2(x, y) {
1414
var hh = 1 + 2;
1515

1616
function f(x) {
17-
des(x, (function () {
17+
des(x, (function (param) {
1818
console.log("hei");
1919
}));
2020
}

jscomp/test/bs_auto_uncurry.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,30 @@ var xs = Array.prototype.map.call([
3636
}));
3737

3838
function f_0(param) {
39-
return hi(function () {
39+
return hi(function (param) {
4040

4141
});
4242
}
4343

4444
function f_01(param) {
45-
return hi(function () {
46-
console.log("x");
45+
return hi(function (x) {
46+
if (x === undefined) {
47+
console.log("x");
48+
return ;
49+
}
50+
4751
});
4852
}
4953

5054
function f_02(xs) {
51-
return hi(function () {
52-
xs.contents = undefined;
55+
return hi(function (x) {
56+
xs.contents = x;
5357
console.log("x");
5458
});
5559
}
5660

5761
function f_03(xs, u) {
58-
return hi(function () {
59-
return Curry._1(u, undefined);
60-
});
62+
return hi(Curry.__1(u));
6163
}
6264

6365
function fishy(x, y, z) {

jscomp/test/bs_auto_uncurry.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ external ff2 :
5252
= "ff2" [@@bs.val]
5353

5454
external
55-
hi: (unit -> unit [@bs.uncurry 0]) -> int = "hi" [@@bs.val]
55+
hi: (unit -> unit [@bs.uncurry 1]) -> int = "hi" [@@bs.val]
5656

5757
(**
5858
fun (_){

jscomp/test/bs_auto_uncurry_test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ var xs = {
3737
contents: /* [] */0
3838
};
3939

40-
hi(function () {
40+
hi(function (x) {
4141
xs.contents = {
42-
hd: undefined,
42+
hd: x,
4343
tl: xs.contents
4444
};
4545
});
4646

47-
hi(function () {
47+
hi(function (x) {
4848
xs.contents = {
49-
hd: undefined,
49+
hd: x,
5050
tl: xs.contents
5151
};
5252
});

jscomp/test/event_ffi.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function ocaml_run(b, c) {
3838
return (x + b | 0) + c | 0;
3939
}
4040

41-
function a0() {
41+
function a0(param) {
4242
console.log("hi");
4343
}
4444

jscomp/test/ffi_arity_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ var hh = [
3939
return parseInt(x);
4040
});
4141

42-
function u() {
42+
function u(param) {
4343
return 3;
4444
}
4545

@@ -53,8 +53,8 @@ function fff(param) {
5353
vvv.contents = vvv.contents + 1 | 0;
5454
}
5555

56-
function g() {
57-
return fff(undefined);
56+
function g(param) {
57+
fff(undefined);
5858
}
5959

6060
function abc(x, y, z) {

0 commit comments

Comments
 (0)