Skip to content

Commit f33af2d

Browse files
committed
simplify check of private assignment
1 parent 2bcf3f7 commit f33af2d

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

compiler/ml/typecore.ml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -313,15 +313,6 @@ let extract_concrete_record env ty =
313313
match extract_concrete_typedecl env ty with
314314
| p0, p, {type_kind = Type_record (fields, repr)} -> (p0, p, fields, repr)
315315
| _ -> raise Not_found
316-
317-
let private_record_allows_mutation env label =
318-
match extract_concrete_typedecl env label.lbl_res with
319-
| _, _, {type_kind = Type_record _; type_private = Private; type_attributes}
320-
->
321-
Builtin_attributes.has_allow_mutation type_attributes
322-
| _ -> false
323-
| exception Not_found -> false
324-
325316
let extract_concrete_variant env ty =
326317
match extract_concrete_typedecl env ty with
327318
| p0, p, {type_kind = Type_variant cstrs} -> (p0, p, cstrs)
@@ -3472,10 +3463,12 @@ and type_label_exp ~call_context create env loc ty_expected
34723463
(* Generalize information merged from ty_expected *)
34733464
generalize_structure ty_arg);
34743465
let allow_private_assignment =
3475-
match call_context with
3476-
| `SetRecordField when not create ->
3477-
private_record_allows_mutation env label
3466+
match extract_concrete_typedecl env label.lbl_res with
3467+
| _, _, {type_kind = Type_record _; type_private = Private; type_attributes}
3468+
when not create ->
3469+
Builtin_attributes.has_allow_mutation type_attributes
34783470
| _ -> false
3471+
| exception Not_found -> false
34793472
in
34803473
if label.lbl_private = Private && not allow_private_assignment then
34813474
if create then raise (Error (loc, env, Private_type ty_expected))

0 commit comments

Comments
 (0)