Skip to content

Commit 0dd79f0

Browse files
authored
Merge pull request #4447 from BuckleScript/fix_4442
fix #4442
2 parents ccb3484 + b9aad43 commit 0dd79f0

File tree

7 files changed

+68
-10
lines changed

7 files changed

+68
-10
lines changed

jscomp/core/classify_function.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let classify (prog : string) : Js_raw_info.exp =
2626
match Parser_flow.parse_expression
2727
(Parser_env.init_env None prog) false with
2828
| (_, Function {
29-
id = None;
29+
id = _;
3030
params = (_, {params});
3131
async = false;
3232
generator = false;

jscomp/test/build.ninja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ build test/gpr_4274_test.cmi test/gpr_4274_test.cmj : cc test/gpr_4274_test.ml |
324324
build test/gpr_4280_test.cmi test/gpr_4280_test.cmj : cc test/gpr_4280_test.ml | test/mt.cmj $stdlib
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
327+
build test/gpr_4442_test.cmi test/gpr_4442_test.cmj : cc test/gpr_4442_test.ml | test/mt.cmj $stdlib
327328
build test/gpr_459_test.cmi test/gpr_459_test.cmj : cc test/gpr_459_test.ml | test/mt.cmj $stdlib
328329
build test/gpr_627_test.cmi test/gpr_627_test.cmj : cc test/gpr_627_test.ml | test/mt.cmj $stdlib
329330
build test/gpr_658.cmi test/gpr_658.cmj : cc test/gpr_658.ml | $stdlib

jscomp/test/gpr_4442_test.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
'use strict';
2+
3+
var Mt = require("./mt.js");
4+
5+
var suites = {
6+
contents: /* [] */0
7+
};
8+
9+
var test_id = {
10+
contents: 0
11+
};
12+
13+
function eq(loc, x, y) {
14+
return Mt.eq_suites(test_id, suites, loc, x, y);
15+
}
16+
17+
var u = (function fib(n){
18+
if(n===0||n==1){
19+
return 1
20+
}
21+
return fib(n-1) + fib(n-2)
22+
});
23+
24+
eq("File \"gpr_4442_test.ml\", line 14, characters 6-13", u(2), 2);
25+
26+
eq("File \"gpr_4442_test.ml\", line 15, characters 6-13", u(3), 3);
27+
28+
Mt.from_pair_suites("gpr_4442_test.ml", suites.contents);
29+
30+
exports.suites = suites;
31+
exports.test_id = test_id;
32+
exports.eq = eq;
33+
exports.u = u;
34+
/* Not a pure module */

jscomp/test/gpr_4442_test.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
let suites : Mt.pair_suites ref = ref []
3+
let test_id = ref 0
4+
let eq loc x y = Mt.eq_suites ~test_id ~suites loc x y
5+
6+
let u = [%raw{|function fib(n){
7+
if(n===0||n==1){
8+
return 1
9+
}
10+
return fib(n-1) + fib(n-2)
11+
}|}]
12+
13+
14+
;; eq __LOC__ (u 2) 2
15+
;; eq __LOC__ (u 3) 3
16+
17+
;; Mt.from_pair_suites __FILE__ !suites

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110651,8 +110651,10 @@ module E = Js_exp_make
110651110651
Note if we inline {!Caml_exceptions.create},
110652110652
it seems can be useful for optimizations in theory,
110653110653
in practice, it never happen, since the pattern match
110654-
never dig into it internally, so maybe {!Obj.set_tag}
110655-
is not necessary at all
110654+
never dig into it internally.
110655+
Alternative is to create a block `["xx"]` which relies on object identity
110656+
We try to avoid this, since inlining would break this, this would make reason
110657+
about the correctness of inlining more difficult
110656110658
*)
110657110659
let make exception_str : J.expression =
110658110660
E.runtime_call Js_runtime_modules.exceptions Literals.create [exception_str]
@@ -395508,7 +395510,7 @@ let classify (prog : string) : Js_raw_info.exp =
395508395510
match Parser_flow.parse_expression
395509395511
(Parser_env.init_env None prog) false with
395510395512
| (_, Function {
395511-
id = None;
395513+
id = _;
395512395514
params = (_, {params});
395513395515
async = false;
395514395516
generator = false;

lib/4.06.1/unstable/js_refmt_compiler.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110651,8 +110651,10 @@ module E = Js_exp_make
110651110651
Note if we inline {!Caml_exceptions.create},
110652110652
it seems can be useful for optimizations in theory,
110653110653
in practice, it never happen, since the pattern match
110654-
never dig into it internally, so maybe {!Obj.set_tag}
110655-
is not necessary at all
110654+
never dig into it internally.
110655+
Alternative is to create a block `["xx"]` which relies on object identity
110656+
We try to avoid this, since inlining would break this, this would make reason
110657+
about the correctness of inlining more difficult
110656110658
*)
110657110659
let make exception_str : J.expression =
110658110660
E.runtime_call Js_runtime_modules.exceptions Literals.create [exception_str]
@@ -395508,7 +395510,7 @@ let classify (prog : string) : Js_raw_info.exp =
395508395510
match Parser_flow.parse_expression
395509395511
(Parser_env.init_env None prog) false with
395510395512
| (_, Function {
395511-
id = None;
395513+
id = _;
395512395514
params = (_, {params});
395513395515
async = false;
395514395516
generator = false;

lib/4.06.1/whole_compiler.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393245,8 +393245,10 @@ module E = Js_exp_make
393245393245
Note if we inline {!Caml_exceptions.create},
393246393246
it seems can be useful for optimizations in theory,
393247393247
in practice, it never happen, since the pattern match
393248-
never dig into it internally, so maybe {!Obj.set_tag}
393249-
is not necessary at all
393248+
never dig into it internally.
393249+
Alternative is to create a block `["xx"]` which relies on object identity
393250+
We try to avoid this, since inlining would break this, this would make reason
393251+
about the correctness of inlining more difficult
393250393252
*)
393251393253
let make exception_str : J.expression =
393252393254
E.runtime_call Js_runtime_modules.exceptions Literals.create [exception_str]
@@ -398996,7 +398998,7 @@ let classify (prog : string) : Js_raw_info.exp =
398996398998
match Parser_flow.parse_expression
398997398999
(Parser_env.init_env None prog) false with
398998399000
| (_, Function {
398999-
id = None;
399001+
id = _;
399000399002
params = (_, {params});
399001399003
async = false;
399002399004
generator = false;

0 commit comments

Comments
 (0)