Skip to content

Commit

Permalink
Fix record error recovery
Browse files Browse the repository at this point in the history
  • Loading branch information
liam923 committed Jan 16, 2025
1 parent 2678281 commit d291bf7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ocaml/typing/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5532,6 +5532,8 @@ and type_expect_
let type_expect_record (type rep) ~overwrite (record_form : rep record_form)
(lid_sexp_list: (Longident.t loc * Parsetree.expression) list)
(opt_sexp : Parsetree.expression option) =
let saved_levels = save_levels () in
begin try
assert (lid_sexp_list <> []);
let opt_exp =
match opt_sexp with
Expand Down Expand Up @@ -5780,6 +5782,20 @@ and type_expect_
exp_type = instance ty_expected;
exp_attributes = sexp.pexp_attributes;
exp_env = env }
with exn ->
raise_error exn;
set_levels saved_levels;
re {
exp_desc = Texp_record {
fields = [||]; representation = Record_boxed [||];
extended_expression = None;
alloc_mode = None
};
exp_loc = loc; exp_extra = [];
exp_type = instance ty_expected;
exp_attributes = Msupport.recovery_attributes sexp.pexp_attributes;
exp_env = env }
end
in
match desc with
| Pexp_ident lid ->
Expand Down

0 comments on commit d291bf7

Please sign in to comment.