Skip to content

Commit 08628d6

Browse files
committed
1 parent 9551c69 commit 08628d6

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

jscomp/core/js_dump.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ let exp_need_paren (e : J.expression) =
167167

168168
| Raw_js_code {code_info = Exp _}
169169
| Fun _
170-
| Caml_block (_,_,_, (Blk_record _ | Blk_module _))
170+
| Caml_block (_,_,_, (Blk_record _ | Blk_module _ | Blk_poly_var _ | Blk_extension | Blk_record_ext _ | Blk_record_inlined _ | Blk_constructor _ ))
171171
| Object _ -> true
172172
| Raw_js_code {code_info = Stmt _ }
173173
| Length _

jscomp/test/build.ninja

+1
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ build test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.ml |
325325
build test/gpr_4407_test.cmi test/gpr_4407_test.cmj : cc test/gpr_4407_test.ml | test/debug_mode_value.cmj test/mt.cmj $stdlib
326326
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib
327327
build test/gpr_4442_test.cmi test/gpr_4442_test.cmj : cc test/gpr_4442_test.ml | test/mt.cmj $stdlib
328+
build test/gpr_4491_test.cmi test/gpr_4491_test.cmj : cc test/gpr_4491_test.ml | $stdlib
328329
build test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib
329330
build test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib
330331
build test/gpr_658.cmi test/gpr_658.cmj : cc test/gpr_658.ml | $stdlib

jscomp/test/gpr_4491_test.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
4+
function f(xs) {
5+
if (xs !== undefined) {
6+
console.log("side effect");
7+
({
8+
hd: xs,
9+
tl: {
10+
hd: xs,
11+
tl: /* [] */0
12+
}
13+
});
14+
} else {
15+
({
16+
hd: 1,
17+
tl: {
18+
hd: 2,
19+
tl: /* [] */0
20+
}
21+
});
22+
}
23+
console.log("nothing to see here", xs);
24+
25+
}
26+
27+
exports.f = f;
28+
/* No side effect */

jscomp/test/gpr_4491_test.ml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let f xs =
2+
let unused =
3+
match xs with
4+
| Some (l) -> Js.log "side effect"; [l; l]
5+
| None -> [1; 2]
6+
in
7+
Js.log2 "nothing to see here" xs

0 commit comments

Comments
 (0)