Skip to content

Commit 1b05598

Browse files
committed
Change strategy to avoid ambiguity after a return statement
When pretty-printing, there is no ambiguity since we always have a space after the return statement. In compact mode, use a newline instead.
1 parent a6a78b7 commit 1b05598

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/lib/js_output.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,8 +1407,14 @@ struct
14071407
let last_semi ?(ret = false) () =
14081408
if can_omit_semi
14091409
then ()
1410-
else if ret && source_map_enabled
1411-
then PP.string f "; "
1410+
else if ret && source_map_enabled && PP.compact f
1411+
then
1412+
(* In Chrome, the debugger will stop right after a return
1413+
statement. We want a whitespace between this statement and
1414+
the next one to avoid confusing this location and the
1415+
location of the next statement. When pretty-printing, this
1416+
is already the case. In compact mode, we add a newline. *)
1417+
PP.string f ";\n"
14121418
else PP.string f ";"
14131419
in
14141420
if stop_on_statement s then output_debug_info f loc;

0 commit comments

Comments
 (0)