Skip to content

Commit 4d1c944

Browse files
committedAug 21, 2024
remove unnecessary parens of iife
1 parent 0410183 commit 4d1c944

9 files changed

+31
-41
lines changed
 

‎jscomp/core/j.ml

-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ and expression_desc =
135135
env : Js_fun_env.t;
136136
return_unit : bool;
137137
async : bool;
138-
iife : bool;
139138
directive : string option;
140139
}
141140
| Str of { delim : delim; txt : string }

‎jscomp/core/js_dump.ml

+7-11
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ let rec try_optimize_curry cxt f len function_id =
301301
Curry_gen.pp_optimize_curry f len;
302302
P.paren_group f 1 (fun _ -> expression ~level:1 cxt f function_id)
303303

304-
and pp_function ~return_unit ~async ~is_method ~iife ?directive cxt (f : P.t) ~fn_state
304+
and pp_function ~return_unit ~async ~is_method ?directive cxt (f : P.t) ~fn_state
305305
(l : Ident.t list) (b : J.block) (env : Js_fun_env.t) : cxt =
306306
match b with
307307
| [
@@ -426,9 +426,8 @@ and pp_function ~return_unit ~async ~is_method ~iife ?directive cxt (f : P.t) ~f
426426
P.string f (L.function_ ~async ~arrow);
427427
param_body ()
428428
| No_name _ ->
429-
P.cond_paren_group f (iife) (fun _ ->
430-
P.string f (L.function_ ~async ~arrow);
431-
param_body ())
429+
P.string f (L.function_ ~async ~arrow);
430+
param_body ()
432431
| Name_non_top x ->
433432
ignore (pp_var_assign inner_cxt f x : cxt);
434433
P.string f (L.function_ ~async ~arrow);
@@ -524,9 +523,9 @@ and expression_desc cxt ~(level : int) f x : cxt =
524523
let cxt = expression ~level:0 cxt f e1 in
525524
comma_sp f;
526525
expression ~level:0 cxt f e2)
527-
| Fun { is_method; params; body; env; return_unit; async; iife; directive } ->
526+
| Fun { is_method; params; body; env; return_unit; async; directive } ->
528527
(* TODO: dump for comments *)
529-
pp_function ?directive ~is_method ~return_unit ~async ~iife
528+
pp_function ?directive ~is_method ~return_unit ~async
530529
~fn_state:default_fn_exp_state
531530
cxt f params body env
532531
(* TODO:
@@ -561,12 +560,11 @@ and expression_desc cxt ~(level : int) f x : cxt =
561560
env;
562561
return_unit;
563562
async;
564-
iife;
565563
directive;
566564
};
567565
};
568566
] ->
569-
pp_function ?directive ~is_method ~return_unit ~async ~iife
567+
pp_function ?directive ~is_method ~return_unit ~async
570568
~fn_state:(No_name { single_arg = true })
571569
cxt f params body env
572570
| _ ->
@@ -970,7 +968,6 @@ and variable_declaration top cxt f (variable : J.variable_declaration) : cxt =
970968
match e.expression_desc with
971969
| Fun { is_method; params; body; env; return_unit; async; directive } ->
972970
pp_function ?directive ~is_method ~return_unit ~async
973-
~iife:false
974971
~fn_state:(if top then Name_top name else Name_non_top name)
975972
cxt f params body env
976973
| _ ->
@@ -1178,10 +1175,9 @@ and statement_desc top cxt f (s : J.statement_desc) : cxt =
11781175
cxt
11791176
| Return e -> (
11801177
match e.expression_desc with
1181-
| Fun { is_method; params; body; env; return_unit; async; iife; directive } ->
1178+
| Fun { is_method; params; body; env; return_unit; async; directive } ->
11821179
let cxt =
11831180
pp_function ?directive ~return_unit ~is_method ~async
1184-
~iife
11851181
~fn_state:Is_return
11861182
cxt f params body env
11871183
in

‎jscomp/core/js_exp_make.ml

+2-5
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ let unit : t = { expression_desc = Undefined {is_unit = true}; comment = None }
207207
[Js_fun_env.empty] is a mutable state ..
208208
*)
209209

210-
let ocaml_fun ?comment ?immutable_mask ?(iife = false) ?directive ~return_unit ~async ~one_unit_arg params body : t =
210+
let ocaml_fun ?comment ?immutable_mask ?directive ~return_unit ~async ~one_unit_arg params body : t =
211211
let params = if one_unit_arg then [] else params in
212212
let len = List.length params in
213213
{
@@ -220,13 +220,12 @@ let ocaml_fun ?comment ?immutable_mask ?(iife = false) ?directive ~return_unit ~
220220
env = Js_fun_env.make ?immutable_mask len;
221221
return_unit;
222222
async;
223-
iife;
224223
directive;
225224
};
226225
comment;
227226
}
228227

229-
let method_ ?comment ?immutable_mask ?(iife = false) ~return_unit params body : t =
228+
let method_ ?comment ?immutable_mask ~return_unit params body : t =
230229
let len = List.length params in
231230
{
232231
expression_desc =
@@ -238,7 +237,6 @@ let method_ ?comment ?immutable_mask ?(iife = false) ~return_unit params body :
238237
env = Js_fun_env.make ?immutable_mask len;
239238
return_unit;
240239
async = false;
241-
iife;
242240
directive = None;
243241
};
244242
comment;
@@ -1305,7 +1303,6 @@ let of_block ?comment ?e block : t =
13051303
env = Js_fun_env.make 0;
13061304
return_unit;
13071305
async = false;
1308-
iife = true;
13091306
directive = None;
13101307
};
13111308
}

‎jscomp/core/js_exp_make.mli

-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ val str : ?delim: J.delim -> ?comment: string -> string -> t
8888
val ocaml_fun :
8989
?comment:string ->
9090
?immutable_mask:bool array ->
91-
?iife:bool ->
9291
?directive:string ->
9392
return_unit:bool ->
9493
async:bool ->
@@ -100,7 +99,6 @@ val ocaml_fun :
10099
val method_ :
101100
?comment:string ->
102101
?immutable_mask:bool array ->
103-
?iife:bool ->
104102
return_unit:bool ->
105103
J.ident list ->
106104
J.block ->

‎jscomp/test/complex_while_loop.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎jscomp/test/ext_string_test.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎jscomp/test/test_while_side_effect.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎lib/es6/caml_format.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,10 @@ function parse_format(fmt) {
404404
case 46 :
405405
f.prec = 0;
406406
let j = i + 1 | 0;
407-
while (((() => {
407+
while ((() => {
408408
let w = fmt.codePointAt(j) - 48 | 0;
409409
return w >= 0 && w <= 9;
410-
}))()) {
410+
})()) {
411411
f.prec = (Math.imul(f.prec, 10) + fmt.codePointAt(j) | 0) - 48 | 0;
412412
j = j + 1 | 0;
413413
};
@@ -443,10 +443,10 @@ function parse_format(fmt) {
443443
case 3 :
444444
f.width = 0;
445445
let j$1 = i;
446-
while (((() => {
446+
while ((() => {
447447
let w = fmt.codePointAt(j$1) - 48 | 0;
448448
return w >= 0 && w <= 9;
449-
}))()) {
449+
})()) {
450450
f.width = (Math.imul(f.width, 10) + fmt.codePointAt(j$1) | 0) - 48 | 0;
451451
j$1 = j$1 + 1 | 0;
452452
};
@@ -676,10 +676,10 @@ function format_float(fmt, x) {
676676
p = p - (exp + 1 | 0) | 0;
677677
s = x$1.toFixed(p);
678678
} else {
679-
while (((() => {
679+
while ((() => {
680680
s = x$1.toFixed(p);
681681
return s.length > (prec$1 + 1 | 0);
682-
}))()) {
682+
})()) {
683683
p = p - 1 | 0;
684684
};
685685
}

‎lib/js/caml_format.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -404,10 +404,10 @@ function parse_format(fmt) {
404404
case 46 :
405405
f.prec = 0;
406406
let j = i + 1 | 0;
407-
while (((() => {
407+
while ((() => {
408408
let w = fmt.codePointAt(j) - 48 | 0;
409409
return w >= 0 && w <= 9;
410-
}))()) {
410+
})()) {
411411
f.prec = (Math.imul(f.prec, 10) + fmt.codePointAt(j) | 0) - 48 | 0;
412412
j = j + 1 | 0;
413413
};
@@ -443,10 +443,10 @@ function parse_format(fmt) {
443443
case 3 :
444444
f.width = 0;
445445
let j$1 = i;
446-
while (((() => {
446+
while ((() => {
447447
let w = fmt.codePointAt(j$1) - 48 | 0;
448448
return w >= 0 && w <= 9;
449-
}))()) {
449+
})()) {
450450
f.width = (Math.imul(f.width, 10) + fmt.codePointAt(j$1) | 0) - 48 | 0;
451451
j$1 = j$1 + 1 | 0;
452452
};
@@ -676,10 +676,10 @@ function format_float(fmt, x) {
676676
p = p - (exp + 1 | 0) | 0;
677677
s = x$1.toFixed(p);
678678
} else {
679-
while (((() => {
679+
while ((() => {
680680
s = x$1.toFixed(p);
681681
return s.length > (prec$1 + 1 | 0);
682-
}))()) {
682+
})()) {
683683
p = p - 1 | 0;
684684
};
685685
}

0 commit comments

Comments
 (0)