From 2922263fab0e073fbcb8d6e39bf2afd48dffd17c Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Sat, 26 Oct 2024 21:42:01 -0700 Subject: [PATCH] refactor: use inline record for `J.Try` (#1196) --- jscomp/core/j.ml | 6 +++++- jscomp/core/js_dump.ml | 2 +- jscomp/core/js_stmt_make.ml | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/jscomp/core/j.ml b/jscomp/core/j.ml index 4d3f33761..4a83ca581 100644 --- a/jscomp/core/j.ml +++ b/jscomp/core/j.ml @@ -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 = { diff --git a/jscomp/core/js_dump.ml b/jscomp/core/js_dump.ml index 8922b2784..ed2d201b4 100644 --- a/jscomp/core/js_dump.ml +++ b/jscomp/core/js_dump.ml @@ -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; diff --git a/jscomp/core/js_stmt_make.ml b/jscomp/core/js_stmt_make.ml index b88c92b41..94330cd52 100644 --- a/jscomp/core/js_stmt_make.ml +++ b/jscomp/core/js_stmt_make.ml @@ -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