Skip to content

Commit e00b589

Browse files
committed
tweak
1 parent f7092b6 commit e00b589

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

jscomp/core/js_output.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ let to_break_block (x : t) : J.block * bool =
117117
let block = unnest_block x.block in
118118
match x with
119119
| {finished = True; _ } ->
120-
block, false
120+
block, false
121121
(* value does not matter when [finished] is true
122122
TODO: check if it has side efects
123123
*)
124124
| { value = None; finished } ->
125125
block, (match finished with | True -> false | (False | Dummy) -> true )
126126

127-
| {value = opt; _} ->
127+
| {value = Some _ as opt; _} ->
128128
block_with_opt_expr block opt, true
129129

130130

jscomp/core/js_output.mli

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@ val output_as_block :
6565
val to_break_block :
6666
t ->
6767
J.block * bool
68+
(* the second argument is
69+
[true] means [break] needed
70+
71+
When we know the output is gonna finished true
72+
we can reduce
73+
{[
74+
return xx ;
75+
break
76+
]}
77+
into
78+
{[
79+
return ;
80+
]}
81+
82+
*)
6883

6984
val append_output: t -> t -> t
7085

lib/whole_compiler.ml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87926,6 +87926,21 @@ val output_as_block :
8792687926
val to_break_block :
8792787927
t ->
8792887928
J.block * bool
87929+
(* the second argument is
87930+
[true] means [break] needed
87931+
87932+
When we know the output is gonna finished true
87933+
we can reduce
87934+
{[
87935+
return xx ;
87936+
break
87937+
]}
87938+
into
87939+
{[
87940+
return ;
87941+
]}
87942+
87943+
*)
8792987944

8793087945
val append_output: t -> t -> t
8793187946

@@ -88077,14 +88092,14 @@ let to_break_block (x : t) : J.block * bool =
8807788092
let block = unnest_block x.block in
8807888093
match x with
8807988094
| {finished = True; _ } ->
88080-
block, false
88095+
block, false
8808188096
(* value does not matter when [finished] is true
8808288097
TODO: check if it has side efects
8808388098
*)
8808488099
| { value = None; finished } ->
8808588100
block, (match finished with | True -> false | (False | Dummy) -> true )
8808688101

88087-
| {value = opt; _} ->
88102+
| {value = Some _ as opt; _} ->
8808888103
block_with_opt_expr block opt, true
8808988104

8809088105

0 commit comments

Comments
 (0)