Skip to content

Commit 6113828

Browse files
committed
non special handling of creation of arity0
1 parent 42675b2 commit 6113828

File tree

5 files changed

+27
-20
lines changed

5 files changed

+27
-20
lines changed

jscomp/runtime/js.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ type +'a t
5757
Absent cmi file when looking up module alias.
5858
*)
5959
module Fn = struct
60-
type + 'a arity0
60+
type 'a arity0 = {
61+
i0 : unit -> 'a [@internal]
62+
}
6163
type 'a arity1 = {
6264
i1 : 'a [@internal]
6365
}
@@ -135,7 +137,7 @@ module Internal = struct
135137
(* Use opaque instead of [._n] to prevent some optimizations happening *)
136138
external run : 'a arity0 -> 'a = "#run"
137139
external opaque : 'a -> 'a = "%opaque"
138-
external mk0 : (unit -> 'a0) -> 'a0 arity0 = "#fn_mk" "0"
140+
139141
end
140142
(**/**)
141143

jscomp/syntax/ast_uncurry_gen.ml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,17 @@ let to_uncurry_fn loc (self : Bs_ast_mapper.mapper) (label : Asttypes.arg_label
9090
Ast_pat.is_unit_cont ~yes:0 ~no:len p
9191
| _ -> len
9292
in
93-
if arity = 0 && label = Nolabel then
94-
let txt =
95-
Longident.Ldot (Ast_literal.Lid.js_internal, "mk0") in
96-
Parsetree.Pexp_apply (Exp.ident {txt;loc} , [ Nolabel, body])
97-
else
98-
begin
99-
Bs_syntaxerr.err_large_arity loc arity;
100-
let arity_s = string_of_int arity in
101-
Parsetree.Pexp_constraint(
102-
Exp.record ~loc [
103-
{
104-
txt = Ast_literal.Lid.hidden_field arity_s;
105-
loc
106-
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
107-
[Typ.any ~loc ()]
108-
)
109-
end
93+
Bs_syntaxerr.err_large_arity loc arity;
94+
let arity_s = string_of_int arity in
95+
Parsetree.Pexp_constraint(
96+
Exp.record ~loc [
97+
{
98+
txt = Ast_literal.Lid.hidden_field arity_s;
99+
loc
100+
},body] None, Typ.constr ~loc {txt = Ldot (Ast_literal.Lid.js_fn,"arity"^arity_s);loc}
101+
[Typ.any ~loc ()]
102+
)
103+
110104

111105

112106

jscomp/test/uncurry_test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ console.log(f21(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
412412

413413
console.log(f22(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21));
414414

415+
function xx() {
416+
while(true) {
417+
continue ;
418+
};
419+
}
420+
415421
exports.f0 = f0;
416422
exports.f1 = f1;
417423
exports.f2 = f2;
@@ -435,4 +441,5 @@ exports.f19 = f19;
435441
exports.f20 = f20;
436442
exports.f21 = f21;
437443
exports.f22 = f22;
444+
exports.xx = xx;
438445
/* Not a pure module */

jscomp/test/uncurry_test.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@ let f22= fun [@bs]a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17
4848
;; f19 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [@bs] |. Js.log
4949
;; f20 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [@bs] |. Js.log
5050
;; f21 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [@bs] |. Js.log
51-
;; f22 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [@bs] |. Js.log
51+
;; f22 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [@bs] |. Js.log
52+
53+
let rec xx = fun [@bs] () -> xx () [@bs]

jscomp/test/uncurry_test.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,3 +264,5 @@ val f22 :
264264
'a * 'b * 'c * 'd * 'e * 'f * 'g * 'h * 'i * 'j * 'k * 'l * 'm * 'n * 'o *
265265
'p * 'q * 'r * 's * 't * 'u * 'v
266266
[@bs])
267+
268+
val xx : unit -> 'a [@bs]

0 commit comments

Comments
 (0)