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
Record coercion can turn an immutable field into a mutable one #9063
So a value typed ro, whose x the type system treats as immutable, can be written through the coerced view:
letr: ro= {x: 0.}
letw= (r :> rw)
w.x=1. // compiles; r.x is now 1.
Where
Record_coercion.check_record_fields (compiler/ml/record_coercion.ml) compares field names, optionality and runtime names, and passes the field types on for subtyping; it does not compare mutability.
Expected
A coercion should not grant write access the source does not have: a mutable target field requires a mutable source field. Where both are mutable, the field type is read and written, so it has to be equal (invariant) rather than a subtype.
Activity
Check field mutability in record coercion (#9086)