From 8ec534db396994281af6c12f532b06af2b2ce154 Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Mon, 13 Jan 2025 22:26:49 -0800 Subject: [PATCH] generated JS: fix for loop formatting (#1296) * generated JS: fix `for` loop formatting * snapshot runtime tests * add changelog entry --- Changes.md | 2 ++ jscomp/core/js_dump.ml | 2 +- jscomp/test/dist/jscomp/test/bdd.js | 4 ++-- jscomp/test/dist/jscomp/test/bench.js | 2 +- .../dist/jscomp/test/bs_mutable_set_test.js | 8 ++++---- .../jscomp/test/bs_poly_mutable_set_test.js | 2 +- .../dist/jscomp/test/class_type_ffi_test.js | 6 +++--- .../test/dist/jscomp/test/complex_if_test.js | 4 ++-- .../dist/jscomp/test/earger_curry_test.js | 2 +- .../test/dist/jscomp/test/ext_array_test.js | 2 +- .../test/dist/jscomp/test/ext_bytes_test.js | 4 ++-- .../dist/jscomp/test/ext_pervasives_test.js | 2 +- .../dist/jscomp/test/flexible_array_test.js | 10 +++++----- jscomp/test/dist/jscomp/test/for_loop_test.js | 8 ++++---- .../dist/jscomp/test/for_side_effect_test.js | 2 +- jscomp/test/dist/jscomp/test/imm_map_bench.js | 2 +- .../dist/jscomp/test/int_overflow_test.js | 4 ++-- .../dist/jscomp/test/ocaml_parsetree_test.js | 12 +++++------ jscomp/test/dist/jscomp/test/ocaml_re_test.js | 2 +- .../dist/jscomp/test/ocaml_typedtree_test.js | 20 +++++++++---------- jscomp/test/dist/jscomp/test/parser_api.js | 18 ++++++++--------- jscomp/test/dist/jscomp/test/qcc.js | 6 +++--- jscomp/test/dist/jscomp/test/sexpm.js | 2 +- .../jscomp/test/stdlib_bytes_utf8_test.js | 16 +++++++-------- jscomp/test/dist/jscomp/test/test_bug.js | 4 ++-- jscomp/test/dist/jscomp/test/test_for_loop.js | 12 +++++------ .../test/dist/jscomp/test/test_internalOO.js | 2 +- 27 files changed, 81 insertions(+), 79 deletions(-) diff --git a/Changes.md b/Changes.md index e6d964310..939a2975e 100644 --- a/Changes.md +++ b/Changes.md @@ -95,6 +95,8 @@ Unreleased ([#1287](https://github.com/melange-re/melange/pull/1287)) - JS generation: remove redundant switch cases branches ([#1295](https://github.com/melange-re/melange/pull/1295)) +- JS generation: move space before comma inside `for` definition + ([#1296](https://github.com/melange-re/melange/pull/1296)) 4.0.1 2024-06-07 --------------- diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index f19256860..154919a24 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -1113,8 +1113,8 @@ and statement_desc top cxt (s : J.statement_desc) : cxt = let cxt = expression ~level:1 cxt ident_expression in - space cxt; comma cxt; + space cxt; let id = Ident.create (Ident.name id ^ "_finish") in let cxt = ident cxt id in space cxt; diff --git a/jscomp/test/dist/jscomp/test/bdd.js b/jscomp/test/dist/jscomp/test/bdd.js index 48c9b7d56..1504cc1a4 100644 --- a/jscomp/test/dist/jscomp/test/bdd.js +++ b/jscomp/test/dist/jscomp/test/bdd.js @@ -96,7 +96,7 @@ function resize(newSize) { } }; }; - for (let n = 0 ,n_finish = sz_1.contents; n <= n_finish; ++n) { + for (let n = 0, n_finish = sz_1.contents; n <= n_finish; ++n) { copyBucket(Caml_array.get(arr, n)); } htab.contents = newArr; @@ -379,7 +379,7 @@ function bool_equal(a, b) { function test_hwb(bdd, vars) { let ntrue = 0; - for (let i = 0 ,i_finish = vars.length; i < i_finish; ++i) { + for (let i = 0, i_finish = vars.length; i < i_finish; ++i) { if (Caml_array.get(vars, i)) { ntrue = ntrue + 1 | 0; } diff --git a/jscomp/test/dist/jscomp/test/bench.js b/jscomp/test/dist/jscomp/test/bench.js index ca87c1632..cc52d9354 100644 --- a/jscomp/test/dist/jscomp/test/bench.js +++ b/jscomp/test/dist/jscomp/test/bench.js @@ -40,7 +40,7 @@ function init(l, f) { function fold_left(f, x, a) { const f$1 = Curry.__2(f); let r = x; - for (let i = 0 ,i_finish = a.length; i < i_finish; ++i) { + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); } return r; diff --git a/jscomp/test/dist/jscomp/test/bs_mutable_set_test.js b/jscomp/test/dist/jscomp/test/bs_mutable_set_test.js index 865465cb4..14d765ae6 100644 --- a/jscomp/test/dist/jscomp/test/bs_mutable_set_test.js +++ b/jscomp/test/dist/jscomp/test/bs_mutable_set_test.js @@ -51,7 +51,7 @@ b("File \"jscomp/test/bs_mutable_set_test.ml\", line 27, characters 4-11", 1 === Belt__Belt_MutableSetInt.add(u, 3); -for (let i = 0 ,i_finish = r.length; i < i_finish; ++i) { +for (let i = 0, i_finish = r.length; i < i_finish; ++i) { Belt__Belt_MutableSetInt.remove(u, r[i]); } @@ -455,7 +455,7 @@ eq("File \"jscomp/test/bs_mutable_set_test.ml\", line 193, characters 5-12", Bel const u$3 = Array_data_util.randomRange(50000, 80000); -for (let i$3 = 0 ,i_finish$1 = u$3.length; i$3 < i_finish$1; ++i$3) { +for (let i$3 = 0, i_finish$1 = u$3.length; i$3 < i_finish$1; ++i$3) { Belt__Belt_MutableSetInt.remove(v$3, i$3); } @@ -463,7 +463,7 @@ eq("File \"jscomp/test/bs_mutable_set_test.ml\", line 200, characters 5-12", Bel const vv = Array_data_util.randomRange(0, 100000); -for (let i$4 = 0 ,i_finish$2 = vv.length; i$4 < i_finish$2; ++i$4) { +for (let i$4 = 0, i_finish$2 = vv.length; i$4 < i_finish$2; ++i$4) { Belt__Belt_MutableSetInt.remove(v$3, Caml_array.get(vv, i$4)); } @@ -493,7 +493,7 @@ eq("File \"jscomp/test/bs_mutable_set_test.ml\", line 216, characters 5-12", Bel const vv$1 = Array_data_util.randomRange(1, 28); -for (let i$5 = 0 ,i_finish$3 = vv$1.length; i$5 < i_finish$3; ++i$5) { +for (let i$5 = 0, i_finish$3 = vv$1.length; i$5 < i_finish$3; ++i$5) { Belt__Belt_MutableSetInt.remove(v$4, Caml_array.get(vv$1, i$5)); } diff --git a/jscomp/test/dist/jscomp/test/bs_poly_mutable_set_test.js b/jscomp/test/dist/jscomp/test/bs_poly_mutable_set_test.js index 9a829d256..318273c67 100644 --- a/jscomp/test/dist/jscomp/test/bs_poly_mutable_set_test.js +++ b/jscomp/test/dist/jscomp/test/bs_poly_mutable_set_test.js @@ -59,7 +59,7 @@ b("File \"jscomp/test/bs_poly_mutable_set_test.ml\", line 25, characters 4-11", Belt__Belt_MutableSet.add(u, 3); -for (let i = 0 ,i_finish = r.length; i < i_finish; ++i) { +for (let i = 0, i_finish = r.length; i < i_finish; ++i) { Belt__Belt_MutableSet.remove(u, r[i]); } diff --git a/jscomp/test/dist/jscomp/test/class_type_ffi_test.js b/jscomp/test/dist/jscomp/test/class_type_ffi_test.js index a12b682e4..93f2f25d4 100644 --- a/jscomp/test/dist/jscomp/test/class_type_ffi_test.js +++ b/jscomp/test/dist/jscomp/test/class_type_ffi_test.js @@ -5,7 +5,7 @@ const Curry = require("melange.js/curry.js"); function sum_float_array(arr) { let v = 0; - for (let i = 0 ,i_finish = arr.length; i < i_finish; ++i) { + for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { v = v + arr.case(i); } return v; @@ -13,7 +13,7 @@ function sum_float_array(arr) { function sum_int_array(arr) { let v = 0; - for (let i = 0 ,i_finish = arr.length; i < i_finish; ++i) { + for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { v = v + arr.case(i) | 0; } return v; @@ -21,7 +21,7 @@ function sum_int_array(arr) { function sum_poly(zero, add, arr) { let v = zero; - for (let i = 0 ,i_finish = arr.length; i < i_finish; ++i) { + for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { v = add(v, arr.case(i)); } return v; diff --git a/jscomp/test/dist/jscomp/test/complex_if_test.js b/jscomp/test/dist/jscomp/test/complex_if_test.js index 5174c5e1e..e3379e5ce 100644 --- a/jscomp/test/dist/jscomp/test/complex_if_test.js +++ b/jscomp/test/dist/jscomp/test/complex_if_test.js @@ -15,7 +15,7 @@ function fib(n) { function escaped(s) { let n = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { const match = s[i]; n = n + ( match >= 32 ? ( @@ -38,7 +38,7 @@ function escaped(s) { } const s$p = Caml_bytes.caml_create_bytes(n); n = 0; - for (let i$1 = 0 ,i_finish$1 = s.length; i$1 < i_finish$1; ++i$1) { + for (let i$1 = 0, i_finish$1 = s.length; i$1 < i_finish$1; ++i$1) { const c = s[i$1]; let exit = 0; if (c >= 35) { diff --git a/jscomp/test/dist/jscomp/test/earger_curry_test.js b/jscomp/test/dist/jscomp/test/earger_curry_test.js index 84ef726a9..95a7cf361 100644 --- a/jscomp/test/dist/jscomp/test/earger_curry_test.js +++ b/jscomp/test/dist/jscomp/test/earger_curry_test.js @@ -41,7 +41,7 @@ function init(l, f) { function fold_left(f, x, a) { const f$1 = Curry.__2(f); let r = x; - for (let i = 0 ,i_finish = a.length; i < i_finish; ++i) { + for (let i = 0, i_finish = a.length; i < i_finish; ++i) { r = f$1(r, a[i]); } return r; diff --git a/jscomp/test/dist/jscomp/test/ext_array_test.js b/jscomp/test/dist/jscomp/test/ext_array_test.js index fb6d4e7fe..fddf5f5ab 100644 --- a/jscomp/test/dist/jscomp/test/ext_array_test.js +++ b/jscomp/test/dist/jscomp/test/ext_array_test.js @@ -12,7 +12,7 @@ function reverse_range(a, i, len) { if (len === 0) { return; } - for (let k = 0 ,k_finish = (len - 1 | 0) / 2 | 0; k <= k_finish; ++k) { + for (let k = 0, k_finish = (len - 1 | 0) / 2 | 0; k <= k_finish; ++k) { const t = a[i + k | 0]; a[i + k | 0] = a[((i + len | 0) - 1 | 0) - k | 0]; a[((i + len | 0) - 1 | 0) - k | 0] = t; diff --git a/jscomp/test/dist/jscomp/test/ext_bytes_test.js b/jscomp/test/dist/jscomp/test/ext_bytes_test.js index 9f85f41cb..41d0f3680 100644 --- a/jscomp/test/dist/jscomp/test/ext_bytes_test.js +++ b/jscomp/test/dist/jscomp/test/ext_bytes_test.js @@ -24,7 +24,7 @@ function eq(loc, x, y) { function escaped(s) { let n = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { const match = s[i]; n = n + ( match >= 32 ? ( @@ -47,7 +47,7 @@ function escaped(s) { } const s$p = Caml_bytes.caml_create_bytes(n); n = 0; - for (let i$1 = 0 ,i_finish$1 = s.length; i$1 < i_finish$1; ++i$1) { + for (let i$1 = 0, i_finish$1 = s.length; i$1 < i_finish$1; ++i$1) { const c = s[i$1]; let exit = 0; if (c >= 35) { diff --git a/jscomp/test/dist/jscomp/test/ext_pervasives_test.js b/jscomp/test/dist/jscomp/test/ext_pervasives_test.js index f7ceed9ed..8410ebb7f 100644 --- a/jscomp/test/dist/jscomp/test/ext_pervasives_test.js +++ b/jscomp/test/dist/jscomp/test/ext_pervasives_test.js @@ -93,7 +93,7 @@ function bad_argf(fmt) { function hash_variant(s) { let accu = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { accu = Math.imul(223, accu) + Caml_string.get(s, i) | 0; } accu = accu & 2147483647; diff --git a/jscomp/test/dist/jscomp/test/flexible_array_test.js b/jscomp/test/dist/jscomp/test/flexible_array_test.js index 26d4f5956..d283dd03f 100644 --- a/jscomp/test/dist/jscomp/test/flexible_array_test.js +++ b/jscomp/test/dist/jscomp/test/flexible_array_test.js @@ -228,7 +228,7 @@ function pop_back(param) { function pp(fmt, s) { let v = "[ "; - for (let i = 0 ,i_finish = length(s); i < i_finish; ++i) { + for (let i = 0, i_finish = length(s); i < i_finish; ++i) { v = v + (", " + String(get(s, i))); } v = v + "]"; @@ -245,7 +245,7 @@ function pp(fmt, s) { function filter_from(i, p, s) { let u = empty; - for (let i$1 = i ,i_finish = length(s); i$1 < i_finish; ++i$1) { + for (let i$1 = i, i_finish = length(s); i$1 < i_finish; ++i$1) { const ele = get(s, i$1); if (Curry._1(p, ele)) { u = push_back(u, ele); @@ -257,10 +257,10 @@ function filter_from(i, p, s) { function append(a, b) { let empty$1 = empty; - for (let i = 0 ,i_finish = length(a); i < i_finish; ++i) { + for (let i = 0, i_finish = length(a); i < i_finish; ++i) { empty$1 = push_back(empty$1, get(a, i)); } - for (let i$1 = 0 ,i_finish$1 = length(b); i$1 < i_finish$1; ++i$1) { + for (let i$1 = 0, i_finish$1 = length(b); i$1 < i_finish$1; ++i$1) { empty$1 = push_back(empty$1, get(b, i$1)); } return empty$1; @@ -283,7 +283,7 @@ function sort(s) { function of_array(arr) { let v = empty; - for (let i = 0 ,i_finish = arr.length; i < i_finish; ++i) { + for (let i = 0, i_finish = arr.length; i < i_finish; ++i) { v = push_back(v, Caml_array.get(arr, i)); } return v; diff --git a/jscomp/test/dist/jscomp/test/for_loop_test.js b/jscomp/test/dist/jscomp/test/for_loop_test.js index 4fb330587..6c1bf22c8 100644 --- a/jscomp/test/dist/jscomp/test/for_loop_test.js +++ b/jscomp/test/dist/jscomp/test/for_loop_test.js @@ -15,7 +15,7 @@ function for_3(x) { }; }), x); - for (let i = 0 ,i_finish = x.length; i < i_finish; ++i) { + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { const j = (i << 1); Caml_array.set(arr, i, (function (param) { v.contents = v.contents + j | 0; @@ -36,7 +36,7 @@ function for_4(x) { }; }), x); - for (let i = 0 ,i_finish = x.length; i < i_finish; ++i) { + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { const j = (i << 1); const k = (j << 1); Caml_array.set(arr, i, (function (param) { @@ -58,7 +58,7 @@ function for_5(x, u) { }; }), x); - for (let i = 0 ,i_finish = x.length; i < i_finish; ++i) { + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { const k = Math.imul((u << 1), u); Caml_array.set(arr, i, (function (param) { v.contents = v.contents + k | 0; @@ -92,7 +92,7 @@ function for_6(x, u) { const v2 = { contents: 0 }; - for (let i = 0 ,i_finish = x.length; i < i_finish; ++i) { + for (let i = 0, i_finish = x.length; i < i_finish; ++i) { const k = Math.imul((u << 1), u); const h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; diff --git a/jscomp/test/dist/jscomp/test/for_side_effect_test.js b/jscomp/test/dist/jscomp/test/for_side_effect_test.js index 7b45060aa..c71f063e0 100644 --- a/jscomp/test/dist/jscomp/test/for_side_effect_test.js +++ b/jscomp/test/dist/jscomp/test/for_side_effect_test.js @@ -4,7 +4,7 @@ const Mt = require("./mt.js"); function tst(param) { - for (let _i = (console.log("hi"), 0) ,_i_finish = (console.log("hello"), 3); _i <= _i_finish; ++_i) { + for (let _i = (console.log("hi"), 0), _i_finish = (console.log("hello"), 3); _i <= _i_finish; ++_i) { } } diff --git a/jscomp/test/dist/jscomp/test/imm_map_bench.js b/jscomp/test/dist/jscomp/test/imm_map_bench.js index 2bae94751..1739da429 100644 --- a/jscomp/test/dist/jscomp/test/imm_map_bench.js +++ b/jscomp/test/dist/jscomp/test/imm_map_bench.js @@ -11,7 +11,7 @@ const empty = new Immutable.OrderedMap(); function fromArray(kvs) { let v = empty; - for (let i = 0 ,i_finish = kvs.length; i < i_finish; ++i) { + for (let i = 0, i_finish = kvs.length; i < i_finish; ++i) { const match = kvs[i]; v = v.set(match[0], match[1]); } diff --git a/jscomp/test/dist/jscomp/test/int_overflow_test.js b/jscomp/test/dist/jscomp/test/int_overflow_test.js index 69fc64107..8d5d25f3f 100644 --- a/jscomp/test/dist/jscomp/test/int_overflow_test.js +++ b/jscomp/test/dist/jscomp/test/int_overflow_test.js @@ -7,7 +7,7 @@ const Stdlib__Int32 = require("melange/int32.js"); function hash_variant(s) { let accu = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { accu = Math.imul(223, accu) + Caml_string.get(s, i) & 2147483647; } if (accu > 1073741823) { @@ -19,7 +19,7 @@ function hash_variant(s) { function hash_variant2(s) { let accu = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { accu = Math.imul(223, accu) + Caml_string.get(s, i) | 0; } accu = accu & 2147483647; diff --git a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js index cca012e53..6c1f16293 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_parsetree_test.js @@ -792,7 +792,7 @@ function parse_opt(error, active, flags, s) { }); } const match$1 = get_range(i); - for (let n = match$1[1] ,n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n) { + for (let n = match$1[1], n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n) { Curry._1(myset, n); } loop(match$1[0]); @@ -1332,7 +1332,7 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { }); } let lines = num_loc_lines.contents; - for (let i = pos0 ,i_finish = lb.lex_buffer_len; i < i_finish; ++i) { + for (let i = pos0, i_finish = lb.lex_buffer_len; i < i_finish; ++i) { if (Caml_bytes.get(lb.lex_buffer, i) === /* '\n' */10) { lines = lines + 1 | 0; } @@ -1347,7 +1347,7 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { Caml_external_polyfill.resolve("caml_terminfo_backup")(lines); let bol = false; Stdlib.print_string("# "); - for (let pos = 0 ,pos_finish = lb.lex_buffer_len - pos0 | 0; pos < pos_finish; ++pos) { + for (let pos = 0, pos_finish = lb.lex_buffer_len - pos0 | 0; pos < pos_finish; ++pos) { if (bol) { Stdlib.print_string(" "); bol = false; @@ -1468,10 +1468,10 @@ function highlight_dumb(ppf, lb, loc) { }, _1: "@. " }); - for (let _i = pos_at_bol ,_i_finish = loc.loc_start.pos_cnum; _i < _i_finish; ++_i) { + for (let _i = pos_at_bol, _i_finish = loc.loc_start.pos_cnum; _i < _i_finish; ++_i) { Stdlib__Format.pp_print_char(ppf, /* ' ' */32); } - for (let _i$1 = loc.loc_start.pos_cnum ,_i_finish$1 = loc.loc_end.pos_cnum; _i$1 < _i_finish$1; ++_i$1) { + for (let _i$1 = loc.loc_start.pos_cnum, _i_finish$1 = loc.loc_end.pos_cnum; _i$1 < _i_finish$1; ++_i$1) { Stdlib__Format.pp_print_char(ppf, /* '^' */94); } } @@ -11846,7 +11846,7 @@ function store_string_char(c) { } function store_string(s) { - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { store_string_char(Caml_string.get(s, i)); } } diff --git a/jscomp/test/dist/jscomp/test/ocaml_re_test.js b/jscomp/test/dist/jscomp/test/ocaml_re_test.js index e6af06aae..8ea5ef6a5 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_re_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_re_test.js @@ -2810,7 +2810,7 @@ function repn(r, i, j) { function set(str) { let s = /* [] */ 0; - for (let i = 0 ,i_finish = str.length; i < i_finish; ++i) { + for (let i = 0, i_finish = str.length; i < i_finish; ++i) { s = union(single(Caml_string.get(str, i)), s); } return { diff --git a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js index 4225b8498..f885441a3 100644 --- a/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js +++ b/jscomp/test/dist/jscomp/test/ocaml_typedtree_test.js @@ -350,7 +350,7 @@ function edit_distance(a, b, cutoff) { Caml_array.set(Caml_array.get(m, 0), j, j); } for (let i$1 = 1; i$1 <= la; ++i$1) { - for (let j$1 = Caml.caml_int_max(1, (i$1 - cutoff$1 | 0) - 1 | 0) ,j_finish = Caml.caml_int_min(lb, (i$1 + cutoff$1 | 0) + 1 | 0); j$1 <= j_finish; ++j$1) { + for (let j$1 = Caml.caml_int_max(1, (i$1 - cutoff$1 | 0) - 1 | 0), j_finish = Caml.caml_int_min(lb, (i$1 + cutoff$1 | 0) + 1 | 0); j$1 <= j_finish; ++j$1) { const cost = Caml_string.get(a, i$1 - 1 | 0) === Caml_string.get(b, j$1 - 1 | 0) ? 0 : 1; const best = Caml.caml_int_min(1 + Caml.caml_int_min(Caml_array.get(Caml_array.get(m, i$1 - 1 | 0), j$1), Caml_array.get(Caml_array.get(m, i$1), j$1 - 1 | 0)) | 0, Caml_array.get(Caml_array.get(m, i$1 - 1 | 0), j$1 - 1 | 0) + cost | 0); const best$1 = i$1 > 1 && j$1 > 1 && Caml_string.get(a, i$1 - 1 | 0) === Caml_string.get(b, j$1 - 2 | 0) && Caml_string.get(a, i$1 - 2 | 0) === Caml_string.get(b, j$1 - 1 | 0) ? Caml.caml_int_min(best, Caml_array.get(Caml_array.get(m, i$1 - 2 | 0), j$1 - 2 | 0) + cost | 0) : best; @@ -1071,7 +1071,7 @@ function parse_opt(error, active, flags, s) { }); } const match$1 = get_range(i); - for (let n = match$1[1] ,n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n) { + for (let n = match$1[1], n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n) { Curry._1(myset, n); } loop(match$1[0]); @@ -1611,7 +1611,7 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { }); } let lines = num_loc_lines.contents; - for (let i = pos0 ,i_finish = lb.lex_buffer_len; i < i_finish; ++i) { + for (let i = pos0, i_finish = lb.lex_buffer_len; i < i_finish; ++i) { if (Caml_bytes.get(lb.lex_buffer, i) === /* '\n' */10) { lines = lines + 1 | 0; } @@ -1626,7 +1626,7 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { Caml_external_polyfill.resolve("caml_terminfo_backup")(lines); let bol = false; Stdlib.print_string("# "); - for (let pos = 0 ,pos_finish = lb.lex_buffer_len - pos0 | 0; pos < pos_finish; ++pos) { + for (let pos = 0, pos_finish = lb.lex_buffer_len - pos0 | 0; pos < pos_finish; ++pos) { if (bol) { Stdlib.print_string(" "); bol = false; @@ -1747,10 +1747,10 @@ function highlight_dumb(ppf, lb, loc) { }, _1: "@. " }); - for (let _i = pos_at_bol ,_i_finish = loc.loc_start.pos_cnum; _i < _i_finish; ++_i) { + for (let _i = pos_at_bol, _i_finish = loc.loc_start.pos_cnum; _i < _i_finish; ++_i) { Stdlib__Format.pp_print_char(ppf, /* ' ' */32); } - for (let _i$1 = loc.loc_start.pos_cnum ,_i_finish$1 = loc.loc_end.pos_cnum; _i$1 < _i_finish$1; ++_i$1) { + for (let _i$1 = loc.loc_start.pos_cnum, _i_finish$1 = loc.loc_end.pos_cnum; _i$1 < _i_finish$1; ++_i$1) { Stdlib__Format.pp_print_char(ppf, /* '^' */94); } } @@ -5438,7 +5438,7 @@ function static_row(row) { function hash_variant(s) { let accu = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { accu = Math.imul(223, accu) + Caml_string.get(s, i) | 0; } accu = accu & 2147483647; @@ -13966,7 +13966,7 @@ function check_value_name(name, loc) { if (!(name.length !== 0 && Caml_string.get(name, 0) === /* '#' */35)) { return; } - for (let i = 1 ,i_finish = name.length; i < i_finish; ++i) { + for (let i = 1, i_finish = name.length; i < i_finish; ++i) { if (Caml_string.get(name, i) === /* '#' */35) { throw new Caml_js_exceptions.MelangeError($$Error$2, { MEL_EXN_ID: $$Error$2, @@ -23986,7 +23986,7 @@ function store_string_char(c) { } function store_string(s) { - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { store_string_char(Caml_string.get(s, i)); } } @@ -64554,7 +64554,7 @@ function check_recordpat_labels(loc, lbl_pat_list, closed) { return; } let $$undefined = /* [] */ 0; - for (let i = 0 ,i_finish = all.length; i < i_finish; ++i) { + for (let i = 0, i_finish = all.length; i < i_finish; ++i) { if (!Caml_array.get(defined, i)) { $$undefined = { hd: Caml_array.get(all, i).lbl_name, diff --git a/jscomp/test/dist/jscomp/test/parser_api.js b/jscomp/test/dist/jscomp/test/parser_api.js index 192b23680..d541668c4 100644 --- a/jscomp/test/dist/jscomp/test/parser_api.js +++ b/jscomp/test/dist/jscomp/test/parser_api.js @@ -1305,7 +1305,7 @@ function for4(param) { function create(str_size) { const tbl_size = Caml_int32.div(str_size, Stdlib__Sys.max_string_length) + 1 | 0; const tbl = Caml_array.make(tbl_size, Stdlib__Bytes.empty); - for (let i = 0 ,i_finish = tbl_size - 2 | 0; i <= i_finish; ++i) { + for (let i = 0, i_finish = tbl_size - 2 | 0; i <= i_finish; ++i) { Caml_array.set(tbl, i, Caml_bytes.caml_create_bytes(Stdlib__Sys.max_string_length)); } Caml_array.set(tbl, tbl_size - 1 | 0, Caml_bytes.caml_create_bytes(Caml_int32.mod_(str_size, Stdlib__Sys.max_string_length))); @@ -1332,7 +1332,7 @@ function blit(src, srcoff, dst, dstoff, len) { } function output(oc, tbl, pos, len) { - for (let i = pos ,i_finish = pos + len | 0; i < i_finish; ++i) { + for (let i = pos, i_finish = pos + len | 0; i < i_finish; ++i) { Caml_io.caml_ml_output_char(oc, get(tbl, i)); } } @@ -1378,7 +1378,7 @@ function edit_distance(a, b, cutoff) { Caml_array.set(Caml_array.get(m, 0), j, j); } for (let i$1 = 1; i$1 <= la; ++i$1) { - for (let j$1 = Caml.caml_int_max(1, (i$1 - cutoff$1 | 0) - 1 | 0) ,j_finish = Caml.caml_int_min(lb, (i$1 + cutoff$1 | 0) + 1 | 0); j$1 <= j_finish; ++j$1) { + for (let j$1 = Caml.caml_int_max(1, (i$1 - cutoff$1 | 0) - 1 | 0), j_finish = Caml.caml_int_min(lb, (i$1 + cutoff$1 | 0) + 1 | 0); j$1 <= j_finish; ++j$1) { const cost = Caml_string.get(a, i$1 - 1 | 0) === Caml_string.get(b, j$1 - 1 | 0) ? 0 : 1; const best = Caml.caml_int_min(1 + Caml.caml_int_min(Caml_array.get(Caml_array.get(m, i$1 - 1 | 0), j$1), Caml_array.get(Caml_array.get(m, i$1), j$1 - 1 | 0)) | 0, Caml_array.get(Caml_array.get(m, i$1 - 1 | 0), j$1 - 1 | 0) + cost | 0); const best$1 = i$1 > 1 && j$1 > 1 && Caml_string.get(a, i$1 - 1 | 0) === Caml_string.get(b, j$1 - 2 | 0) && Caml_string.get(a, i$1 - 2 | 0) === Caml_string.get(b, j$1 - 1 | 0) ? Caml.caml_int_min(best, Caml_array.get(Caml_array.get(m, i$1 - 2 | 0), j$1 - 2 | 0) + cost | 0) : best; @@ -2216,7 +2216,7 @@ function parse_opt(error, active, flags, s) { }); } const match$1 = get_range(i); - for (let n = match$1[1] ,n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n) { + for (let n = match$1[1], n_finish = Caml.caml_int_min(match$1[2], 104); n <= n_finish; ++n) { Curry._1(myset, n); } loop(match$1[0]); @@ -3255,7 +3255,7 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { }); } let lines = num_loc_lines.contents; - for (let i = pos0 ,i_finish = lb.lex_buffer_len; i < i_finish; ++i) { + for (let i = pos0, i_finish = lb.lex_buffer_len; i < i_finish; ++i) { if (Caml_bytes.get(lb.lex_buffer, i) === /* '\n' */10) { lines = lines + 1 | 0; } @@ -3270,7 +3270,7 @@ function highlight_terminfo(ppf, num_lines, lb, locs) { Caml_external_polyfill.resolve("caml_terminfo_backup")(lines); let bol = false; Stdlib.print_string("# "); - for (let pos = 0 ,pos_finish = lb.lex_buffer_len - pos0 | 0; pos < pos_finish; ++pos) { + for (let pos = 0, pos_finish = lb.lex_buffer_len - pos0 | 0; pos < pos_finish; ++pos) { if (bol) { Stdlib.print_string(" "); bol = false; @@ -3391,10 +3391,10 @@ function highlight_dumb(ppf, lb, loc) { }, _1: "@. " }); - for (let _i = pos_at_bol ,_i_finish = loc.loc_start.pos_cnum; _i < _i_finish; ++_i) { + for (let _i = pos_at_bol, _i_finish = loc.loc_start.pos_cnum; _i < _i_finish; ++_i) { Stdlib__Format.pp_print_char(ppf, /* ' ' */32); } - for (let _i$1 = loc.loc_start.pos_cnum ,_i_finish$1 = loc.loc_end.pos_cnum; _i$1 < _i_finish$1; ++_i$1) { + for (let _i$1 = loc.loc_start.pos_cnum, _i_finish$1 = loc.loc_end.pos_cnum; _i$1 < _i_finish$1; ++_i$1) { Stdlib__Format.pp_print_char(ppf, /* '^' */94); } } @@ -15077,7 +15077,7 @@ function store_string_char(c) { } function store_string(s) { - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { store_string_char(Caml_string.get(s, i)); } } diff --git a/jscomp/test/dist/jscomp/test/qcc.js b/jscomp/test/dist/jscomp/test/qcc.js index 9f4719374..0c56dcdda 100644 --- a/jscomp/test/dist/jscomp/test/qcc.js +++ b/jscomp/test/dist/jscomp/test/qcc.js @@ -112,7 +112,7 @@ function symstr(n) { } function symitr(f) { - for (let i = 0 ,i_finish = syms.contents; i < i_finish; ++i) { + for (let i = 0, i_finish = syms.contents; i < i_finish; ++i) { Curry._2(f, i, Caml_array.get(symtab, i)); } } @@ -354,7 +354,7 @@ function out(x) { } function le(n, x) { - for (let i = 0 ,i_finish = n / 8 | 0; i < i_finish; ++i) { + for (let i = 0, i_finish = n / 8 | 0; i < i_finish; ++i) { const $$byte = (x >>> (i << 3)) & 255; Caml_bytes.set(obuf, opos.contents, Stdlib__Char.chr($$byte)); opos.contents = opos.contents + 1 | 0; @@ -966,7 +966,7 @@ function unary(stk) { _1: "[cast] expected" }); } - for (let _k = 1 ,_k_finish = match[1]; _k <= _k_finish; ++_k) { + for (let _k = 1, _k_finish = match[1]; _k <= _k_finish; ++_k) { Curry._1(next$1, undefined); } unary(stk); diff --git a/jscomp/test/dist/jscomp/test/sexpm.js b/jscomp/test/dist/jscomp/test/sexpm.js index 0a523c72c..a842896e5 100644 --- a/jscomp/test/dist/jscomp/test/sexpm.js +++ b/jscomp/test/dist/jscomp/test/sexpm.js @@ -37,7 +37,7 @@ function _with_in(filename, f) { function _must_escape(s) { try { - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { const c = s.charCodeAt(i); let exit = 0; if (c >= 42) { diff --git a/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js b/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js index c6718100e..7b2bf26b8 100644 --- a/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js +++ b/jscomp/test/dist/jscomp/test/stdlib_bytes_utf8_test.js @@ -316,13 +316,13 @@ function uchar_map_of_spec(spec) { } }; - for (let b0 = 0 < len ? Caml_array.get(bytes, 0)[0] : Stdlib.max_int ,b0_finish = 0 < len ? Caml_array.get(bytes, 0)[1] : Stdlib.min_int; b0 <= b0_finish; ++b0) { + for (let b0 = 0 < len ? Caml_array.get(bytes, 0)[0] : Stdlib.max_int, b0_finish = 0 < len ? Caml_array.get(bytes, 0)[1] : Stdlib.min_int; b0 <= b0_finish; ++b0) { Caml_bytes.set(buf, 0, b0); - for (let b1 = 1 < len ? Caml_array.get(bytes, 1)[0] : Stdlib.max_int ,b1_finish = 1 < len ? Caml_array.get(bytes, 1)[1] : Stdlib.min_int; b1 <= b1_finish; ++b1) { + for (let b1 = 1 < len ? Caml_array.get(bytes, 1)[0] : Stdlib.max_int, b1_finish = 1 < len ? Caml_array.get(bytes, 1)[1] : Stdlib.min_int; b1 <= b1_finish; ++b1) { Caml_bytes.set(buf, 1, b1); - for (let b2 = 2 < len ? Caml_array.get(bytes, 2)[0] : Stdlib.max_int ,b2_finish = 2 < len ? Caml_array.get(bytes, 2)[1] : Stdlib.min_int; b2 <= b2_finish; ++b2) { + for (let b2 = 2 < len ? Caml_array.get(bytes, 2)[0] : Stdlib.max_int, b2_finish = 2 < len ? Caml_array.get(bytes, 2)[1] : Stdlib.min_int; b2 <= b2_finish; ++b2) { Caml_bytes.set(buf, 2, b2); - for (let b3 = 3 < len ? Caml_array.get(bytes, 3)[0] : Stdlib.max_int ,b3_finish = 3 < len ? Caml_array.get(bytes, 3)[1] : Stdlib.min_int; b3 <= b3_finish; ++b3) { + for (let b3 = 3 < len ? Caml_array.get(bytes, 3)[0] : Stdlib.max_int, b3_finish = 3 < len ? Caml_array.get(bytes, 3)[1] : Stdlib.min_int; b3 <= b3_finish; ++b3) { Caml_bytes.set(buf, 3, b3); add(4); } @@ -361,7 +361,7 @@ function swap(_u, b) { if (len === 0) { return; } - for (let i = 0 ,i_finish = (b.length >> 1); i < i_finish; ++i) { + for (let i = 0, i_finish = (b.length >> 1); i < i_finish; ++i) { const j = (i << 1); Stdlib__Bytes.set_uint16_le(b, j, Stdlib__Bytes.get_uint16_be(b, j)); } @@ -569,7 +569,7 @@ function ok(i) { return i === (b$2.length - 1 | 0); } -for (let i = 0 ,i_finish = b$2.length; i < i_finish; ++i) { +for (let i = 0, i_finish = b$2.length; i < i_finish; ++i) { const dec = Stdlib__Bytes.get_utf_8_uchar(b$2, i); if (ok(i)) { if ((dec >>> 27) === 1 !== true) { @@ -644,7 +644,7 @@ function ok$1(i) { return i === (b$3.length - 1 | 0); } -for (let i$1 = 0 ,i_finish$1 = b$3.length; i$1 < i_finish$1; ++i$1) { +for (let i$1 = 0, i_finish$1 = b$3.length; i$1 < i_finish$1; ++i$1) { const dec$1 = Stdlib__Bytes.get_utf_8_uchar(b$3, i$1); if (ok$1(i$1)) { if ((dec$1 >>> 27) === 1 !== true) { @@ -723,7 +723,7 @@ function ok$2(i) { } } -for (let i$2 = 0 ,i_finish$2 = b$4.length; i$2 < i_finish$2; ++i$2) { +for (let i$2 = 0, i_finish$2 = b$4.length; i$2 < i_finish$2; ++i$2) { const dec$2 = Stdlib__Bytes.get_utf_8_uchar(b$4, i$2); if (ok$2(i$2)) { if ((dec$2 >>> 27) === 1 !== true) { diff --git a/jscomp/test/dist/jscomp/test/test_bug.js b/jscomp/test/dist/jscomp/test/test_bug.js index cca9e87e7..ddd675888 100644 --- a/jscomp/test/dist/jscomp/test/test_bug.js +++ b/jscomp/test/dist/jscomp/test/test_bug.js @@ -7,7 +7,7 @@ const Test_char = require("./test_char.js"); function escaped(s) { let n = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { const c = s[i]; let tmp; let exit = 0; @@ -38,7 +38,7 @@ function escaped(s) { } const s$p = Caml_bytes.caml_create_bytes(n); n = 0; - for (let i$1 = 0 ,i_finish$1 = s.length; i$1 < i_finish$1; ++i$1) { + for (let i$1 = 0, i_finish$1 = s.length; i$1 < i_finish$1; ++i$1) { const c$1 = s[i$1]; let exit$1 = 0; if (c$1 > 92 || c$1 < 34) { diff --git a/jscomp/test/dist/jscomp/test/test_for_loop.js b/jscomp/test/dist/jscomp/test/test_for_loop.js index 34cd4c7e8..00f76f5e8 100644 --- a/jscomp/test/dist/jscomp/test/test_for_loop.js +++ b/jscomp/test/dist/jscomp/test/test_for_loop.js @@ -6,13 +6,13 @@ const Curry = require("melange.js/curry.js"); const Stdlib__Array = require("melange/array.js"); function for_(x) { - for (let i = 0 ,i_finish = (console.log("hi"), x.length); i <= i_finish; ++i) { + for (let i = 0, i_finish = (console.log("hi"), x.length); i <= i_finish; ++i) { console.log(Caml_array.get(x, i)); } } function for_2(x) { - for (let i = 0 ,i_finish = x.length; i <= i_finish; ++i) { + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { console.log(Caml_array.get(x, i)); } } @@ -26,7 +26,7 @@ function for_3(x) { }; }), x); - for (let i = 0 ,i_finish = x.length; i <= i_finish; ++i) { + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { const j = (i << 1); Caml_array.set(arr, i, (function (param) { v.contents = v.contents + j | 0; @@ -47,7 +47,7 @@ function for_4(x) { }; }), x); - for (let i = 0 ,i_finish = x.length; i <= i_finish; ++i) { + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { const j = (i << 1); const k = (j << 1); Caml_array.set(arr, i, (function (param) { @@ -69,7 +69,7 @@ function for_5(x, u) { }; }), x); - for (let i = 0 ,i_finish = x.length; i <= i_finish; ++i) { + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { const k = Math.imul((u << 1), u); Caml_array.set(arr, i, (function (param) { v.contents = v.contents + k | 0; @@ -102,7 +102,7 @@ function for_6(x, u) { const v2 = { contents: 0 }; - for (let i = 0 ,i_finish = x.length; i <= i_finish; ++i) { + for (let i = 0, i_finish = x.length; i <= i_finish; ++i) { const k = Math.imul((u << 1), u); const h = (v5.contents << 1); v2.contents = v2.contents + 1 | 0; diff --git a/jscomp/test/dist/jscomp/test/test_internalOO.js b/jscomp/test/dist/jscomp/test/test_internalOO.js index 1adf3f8e9..db0180a78 100644 --- a/jscomp/test/dist/jscomp/test/test_internalOO.js +++ b/jscomp/test/dist/jscomp/test/test_internalOO.js @@ -32,7 +32,7 @@ const step = Stdlib__Sys.word_size / 16 | 0; function public_method_label(s) { let accu = 0; - for (let i = 0 ,i_finish = s.length; i < i_finish; ++i) { + for (let i = 0, i_finish = s.length; i < i_finish; ++i) { accu = Math.imul(223, accu) + Caml_string.get(s, i) | 0; } accu = accu & 2147483647;