Skip to content

Commit 07eb788

Browse files
committed
fix #3980
1 parent 24e2d1d commit 07eb788

File tree

8 files changed

+74
-4
lines changed

8 files changed

+74
-4
lines changed

jscomp/core/js_dump.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ let exp_need_paren (e : J.expression) =
171171
| Raw_js_code (_, Exp)
172172
| Fun _
173173
| Raw_js_function _
174+
| Caml_block (_,_,_, (Blk_record _ | Blk_module _))
174175
| Object _ -> true
175176
| Raw_js_code (_,Stmt)
176177
| Length _

jscomp/test/build.ninja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ build test/gpr_3877_test.cmi test/gpr_3877_test.cmj : cc test/gpr_3877_test.ml |
312312
build test/gpr_3895_test.cmi test/gpr_3895_test.cmj : cc test/gpr_3895_test.ml | $stdlib
313313
build test/gpr_3897_test.cmi test/gpr_3897_test.cmj : cc test/gpr_3897_test.ml | $stdlib
314314
build test/gpr_3931_test.cmi test/gpr_3931_test.cmj : cc test/gpr_3931_test.ml | $stdlib
315+
build test/gpr_3980_test.cmi test/gpr_3980_test.cmj : cc test/gpr_3980_test.ml | $stdlib
315316
build test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.ml | test/gpr_405_test.cmi $stdlib
316317
build test/gpr_405_test.cmi : cc test/gpr_405_test.mli | $stdlib
317318
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib

jscomp/test/gpr_3980_test.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
var Js_math = require("../../lib/js/js_math.js");
4+
var Caml_builtin_exceptions = require("../../lib/js/caml_builtin_exceptions.js");
5+
6+
var match = 1;
7+
8+
if (match !== undefined) {
9+
if (match !== 1) {
10+
throw [
11+
Caml_builtin_exceptions.assert_failure,
12+
/* tuple */[
13+
"gpr_3980_test.ml",
14+
16,
15+
10
16+
]
17+
];
18+
}
19+
var match$1 = (1);
20+
if (match$1 !== 1) {
21+
if (match$1 !== 2) {
22+
throw [
23+
Caml_builtin_exceptions.assert_failure,
24+
/* tuple */[
25+
"gpr_3980_test.ml",
26+
14,
27+
12
28+
]
29+
];
30+
}
31+
({
32+
name: "bye",
33+
age: Js_math.floor(1)
34+
});
35+
}
36+
37+
} else {
38+
throw [
39+
Caml_builtin_exceptions.assert_failure,
40+
/* tuple */[
41+
"gpr_3980_test.ml",
42+
16,
43+
10
44+
]
45+
];
46+
}
47+
48+
/* Not a pure module */

jscomp/test/gpr_3980_test.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
type student = {
2+
name: string;
3+
age: int;
4+
}
5+
let _ =
6+
match (Some 1) with
7+
| Some 1 ->
8+
(match [%raw "1"] with
9+
| 1 -> {name = "hi"; age = 1}
10+
| 2 -> {
11+
name = "bye";
12+
age = Js.Math.floor 1.
13+
}
14+
| _ -> assert false
15+
)
16+
| _ -> assert false

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97265,6 +97265,7 @@ let exp_need_paren (e : J.expression) =
9726597265
| Raw_js_code (_, Exp)
9726697266
| Fun _
9726797267
| Raw_js_function _
97268+
| Caml_block (_,_,_, (Blk_record _ | Blk_module _))
9726897269
| Object _ -> true
9726997270
| Raw_js_code (_,Stmt)
9727097271
| Length _

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97265,6 +97265,7 @@ let exp_need_paren (e : J.expression) =
9726597265
| Raw_js_code (_, Exp)
9726697266
| Fun _
9726797267
| Raw_js_function _
97268+
| Caml_block (_,_,_, (Blk_record _ | Blk_module _))
9726897269
| Object _ -> true
9726997270
| Raw_js_code (_,Stmt)
9727097271
| Length _

lib/4.06.1/whole_compiler.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99980,6 +99980,7 @@ let exp_need_paren (e : J.expression) =
9998099980
| Raw_js_code (_, Exp)
9998199981
| Fun _
9998299982
| Raw_js_function _
99983+
| Caml_block (_,_,_, (Blk_record _ | Blk_module _))
9998399984
| Object _ -> true
9998499985
| Raw_js_code (_,Stmt)
9998599986
| Length _

scripts/dbg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
var cp = require("child_process");
33
var path = require("path");
44

5-
var file = process.argv[2]
6-
console.log(file)
5+
var file = process.argv[2];
6+
console.log(file);
77
var fmt = path.parse(file);
88

99
process.env.BS_DEBUG_FILE = file;
10-
11-
cp.execSync(`touch ${file} && ninja ${fmt.dir}/${fmt.name}.cmj`, {
10+
var ninja = path.join(__dirname, "..", "vendor", "ninja", "snapshot",
11+
`ninja${require('./config.js').sys_extension}`);
12+
cp.execSync(`touch ${file} && ${ninja} ${fmt.dir}/${fmt.name}.cmj`, {
1213
stdio: [0, 1, 2]
1314
});

0 commit comments

Comments
 (0)