You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty record literal {} with a mutable optional field is generalized (unsound) #9150
An empty record literal {} of a record type whose fields are all optional generalizes the record's type variables, even when a field is mutable. One binding can then be written at one type and read at another:
The value restriction (Typecore.is_nonexpansive) treats a record literal as non-expansive when none of its fields is mutable. For {}, the type checker builds a Texp_record with an empty fields array (the [], Some representation when lid_sexp_list = [] case in type_expect_), so there is no field, and no label, to check, and the literal counts as non-expansive. A mutable record allocation must be expansive whether or not the literal writes its mutable fields.
Found while fixing the same problem for literals that leave out mutable optional fields in #9149, which now checks all labels of the record (lbl_all) when there is no spread. {} carries no label to reach lbl_all through, so it needs its own fix.
Activity
Treat an empty record literal with mutable fields as expansive
Treat an empty record literal with mutable fields as expansive (#9152)
Treat an empty record literal with mutable fields as expansive (rescr…