Explain why a variant's inline record cannot be coerced
Why
A coercion that fails on an inline record field said only that one variant is not a subtype of the other; since #9086 that includes an immutable field coerced to a mutable one. Plain records name the field. The record messages for a missing field and an @as mismatch also named the two records the wrong way round.
modifiedDiagnostic inline record coercion
type v1 = A({x: float})type v2 = A({mutable x: float})let toV2 = (a: v1) => (a :> v2)
diagnostic
Before
After
Type v1 is not a subtype of v2Type v1 is not a subtype of v2 The record v1.A cannot be coerced to the record v2.A because:- The field x is mutable in record v2.A, but not in record v1.A. A coercion can't make a field writable.
modifiedDiagnostic missing record field
type x = {x: int}type y = {x: int, z: int}let toY = (a: x) => (a :> y)
diagnostic
Before
After
- The field z is missing in record y, but present in record x- The field z is missing in record x, but present in record y
Review
- Why only the first failing constructor? The error has one context; the first constructor whose fields fail is reported.
- A different field type in an inline record still gives no reason; acceptance there is unchanged.