Skip to content

Commit d291bf7

Browse files
committed
Fix record error recovery
1 parent 2678281 commit d291bf7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/ocaml/typing/typecore.ml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5532,6 +5532,8 @@ and type_expect_
55325532
let type_expect_record (type rep) ~overwrite (record_form : rep record_form)
55335533
(lid_sexp_list: (Longident.t loc * Parsetree.expression) list)
55345534
(opt_sexp : Parsetree.expression option) =
5535+
let saved_levels = save_levels () in
5536+
begin try
55355537
assert (lid_sexp_list <> []);
55365538
let opt_exp =
55375539
match opt_sexp with
@@ -5780,6 +5782,20 @@ and type_expect_
57805782
exp_type = instance ty_expected;
57815783
exp_attributes = sexp.pexp_attributes;
57825784
exp_env = env }
5785+
with exn ->
5786+
raise_error exn;
5787+
set_levels saved_levels;
5788+
re {
5789+
exp_desc = Texp_record {
5790+
fields = [||]; representation = Record_boxed [||];
5791+
extended_expression = None;
5792+
alloc_mode = None
5793+
};
5794+
exp_loc = loc; exp_extra = [];
5795+
exp_type = instance ty_expected;
5796+
exp_attributes = Msupport.recovery_attributes sexp.pexp_attributes;
5797+
exp_env = env }
5798+
end
57835799
in
57845800
match desc with
57855801
| Pexp_ident lid ->

0 commit comments

Comments
 (0)