Skip to content

Commit

Permalink
refactor: use inline record for J.Try (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro authored Oct 27, 2024
1 parent 37577ac commit 2922263
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion jscomp/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,11 @@ and statement_desc =
default : block option;
}
| Throw of expression
| Try of block * (exception_ident * block) option * block option
| Try of {
body : block;
catch : (exception_ident * block) option;
finally : block option;
}
| Debugger

and expression = {
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_dump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ and statement_desc top cxt (s : J.statement_desc) : cxt =
cxt)
(* There must be a space between the return and its
argument. A line return would not work *)
| Try (b, ctch, fin) ->
| Try { body = b; catch = ctch; finally = fin } ->
vgroup cxt 0 (fun _ ->
string cxt L.try_;
space cxt;
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/js_stmt_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ let for_ ?comment for_ident_expression finish_ident_expression id direction
}

let try_ ?comment ?with_ ?finally body : t =
{ statement_desc = Try (body, with_, finally); comment }
{ statement_desc = Try { body; catch = with_; finally }; comment }

(* TODO:
actually, only loops can be labelled
Expand Down

0 comments on commit 2922263

Please sign in to comment.