Skip to content

Commit 64cbee1

Browse files
authored
Merge pull request #3879 from BuckleScript/gpr_3875
Fix #3875
2 parents ad092f5 + 28e63aa commit 64cbee1

15 files changed

+3307
-3000
lines changed

jscomp/core/lam_compile.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,9 @@ and compile_staticcatch (lam : Lam.t) (lambda_cxt : Lam_compile_context.t)=
760760
let exit_id = Ext_ident.create_tmp ~name:"exit" () in
761761
match lambda_cxt.continuation, code_table with
762762
| EffectCall (Maybe_tail_is_return (Tail_with_name ({in_staticcatch = false} as z))),
763-
[ code_table ] (* tail position and only one exit code *)
763+
[ code_table ]
764+
(* tail position and only one exit code *)
765+
when Lam_compile_context.no_static_raise_in_handler code_table
764766
->
765767
let jmp_table, handler =
766768
Lam_compile_context.add_pseudo_jmp

jscomp/core/lam_compile_context.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ type handler = {
9999
bindings : Ident.t list;
100100
}
101101

102+
let no_static_raise_in_handler (x : handler) : bool =
103+
not (Lam_exit_code.has_exit_code
104+
x.handler (fun _code -> true))
105+
102106
(* always keep key id positive, specifically no [0] generated
103107
return a tuple
104108
[tbl, handlers]

jscomp/core/lam_compile_context.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ type handler = {
106106
bindings : Ident.t list;
107107
}
108108

109+
val no_static_raise_in_handler :
110+
handler ->
111+
bool
112+
109113
val add_jmps :
110114
jmp_table ->
111115
Ident.t ->

jscomp/test/build.ninja

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ build test/gpr_3852_effect.cmi test/gpr_3852_effect.cmj : cc test/gpr_3852_effec
304304
build test/gpr_3865.cmi test/gpr_3865.cmj : cc test/gpr_3865.re | test/gpr_3865_bar.cmj test/gpr_3865_foo.cmj $stdlib
305305
build test/gpr_3865_bar.cmi test/gpr_3865_bar.cmj : cc test/gpr_3865_bar.re | $stdlib
306306
build test/gpr_3865_foo.cmi test/gpr_3865_foo.cmj : cc test/gpr_3865_foo.re | $stdlib
307+
build test/gpr_3875_test.cmi test/gpr_3875_test.cmj : cc test/gpr_3875_test.ml | test/mt.cmj $stdlib
307308
build test/gpr_405_test.cmj : cc_cmi test/gpr_405_test.ml | test/gpr_405_test.cmi $stdlib
308309
build test/gpr_405_test.cmi : cc test/gpr_405_test.mli | $stdlib
309310
build test/gpr_441.cmi test/gpr_441.cmj : cc test/gpr_441.ml | $stdlib

0 commit comments

Comments
 (0)