Skip to content

Commit a54ea03

Browse files
authored
Merge pull request #2738 from BuckleScript/fix_2731
fix #2731
2 parents 26abbd2 + baf25d6 commit a54ea03

File tree

6 files changed

+51
-2
lines changed

6 files changed

+51
-2
lines changed

jscomp/core/lam_analysis.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
260260
*)
261261
exception Too_big_to_inline
262262

263-
let really_big () = raise Too_big_to_inline
263+
let really_big () = raise_notrace Too_big_to_inline
264264

265265
let big_lambda = 1000
266266

@@ -278,6 +278,8 @@ let rec size (lam : Lam.t) =
278278
| Lprim {primitive = Praise ; args = [l ]; _}
279279
-> size l
280280
| Lam.Lglobal_module _ -> 1
281+
| Lprim {primitive = Praw_js_code_exp _ | Praw_js_code_stmt _} ->
282+
really_big ()
281283
| Lprim {args = ll; _} -> size_lams 1 ll
282284

283285
(** complicated

jscomp/test/.depend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ gpr_2633_test.cmj :
312312
gpr_2642_test.cmj :
313313
gpr_2652_test.cmj : ../others/node.cmj ../stdlib/buffer.cmj
314314
gpr_2700_test.cmj :
315+
gpr_2731_test.cmj :
315316
gpr_405_test.cmj : ../stdlib/hashtbl.cmj gpr_405_test.cmi
316317
gpr_441.cmj :
317318
gpr_459_test.cmj : mt.cmj

jscomp/test/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ OTHERS := test_literals a test_ari test_export2 test_internalOO test_obj_simple_
250250
gpr_2652_test\
251251
gpr_2614_test\
252252
gpr_2700_test\
253+
gpr_2731_test\
253254
# bs_uncurry_test
254255
# needs Lam to get rid of Uncurry arity first
255256
# simple_derive_test

jscomp/test/gpr_2731_test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict';
2+
3+
4+
function f(x) {
5+
return x + (1) | 0;
6+
}
7+
8+
var a = f(1);
9+
10+
var b = f(2);
11+
12+
function g() {
13+
return (1);
14+
}
15+
16+
var c = g(/* () */0);
17+
18+
var d = g(/* () */0);
19+
20+
exports.f = f;
21+
exports.a = a;
22+
exports.b = b;
23+
exports.g = g;
24+
exports.c = c;
25+
exports.d = d;
26+
/* a Not a pure module */

jscomp/test/gpr_2731_test.ml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
4+
let f x = x + [%raw{|1|}]
5+
6+
7+
8+
9+
let a = f 1
10+
let b = f 2
11+
12+
let g () =
13+
[%raw{|1|}]
14+
15+
16+
let c = g ()
17+
let d = g ()

lib/whole_compiler.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86560,7 +86560,7 @@ let rec no_side_effects (lam : Lam.t) : bool =
8656086560
*)
8656186561
exception Too_big_to_inline
8656286562

86563-
let really_big () = raise Too_big_to_inline
86563+
let really_big () = raise_notrace Too_big_to_inline
8656486564

8656586565
let big_lambda = 1000
8656686566

@@ -86578,6 +86578,8 @@ let rec size (lam : Lam.t) =
8657886578
| Lprim {primitive = Praise ; args = [l ]; _}
8657986579
-> size l
8658086580
| Lam.Lglobal_module _ -> 1
86581+
| Lprim {primitive = Praw_js_code_exp _ | Praw_js_code_stmt _} ->
86582+
really_big ()
8658186583
| Lprim {args = ll; _} -> size_lams 1 ll
8658286584

8658386585
(** complicated

0 commit comments

Comments
 (0)