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
Commit 594ff28
Browse filesBrowse the repository at this point in the historyBrowse files
Compare constructor representations in interfaces and coercions alike
Why:
An interface or a coercion accepted a tagged constructor for an
`@unboxed` one: inclusion compared only the tags of tagged constructors,
and the coercion check only the declared `@as` (#9038). The coercion
error also said that the wrong variant was unboxed.
`Variant_runtime.same_representation` compares two constructors: constant
with the same literal, tagged with the same tag, or both untagged. Interface
inclusion and the coercion check use it. Type declarations in messages print
the `@unboxed` of an untagged constructor of a type that is not `@unboxed`
itself, and an interface mismatch names the constructor that is `@unboxed`
in only one declaration. The predefined `unknown`, an
`@unboxed` variant, now has the untagged layout a declaration of it gets, so
`@unboxed type rec t = unknown = Unknown(_): t` still agrees with it.
Diagnostic added (interface with an @unboxed constructor):
Example:
module M: {
type t = | @unboxed A(int) | B({x: int})
} = {
type t = | A(int) | B({x: int})
}
Before (diagnostic): none; clients read {TAG: "A", _0: 3} as B
After (diagnostic):
Type declarations do not match:
type t = A(int) | B({x: int})
is not included in
type t = @unboxed A(int) | B({x: int})
Their internal representations differ:
case A is @unboxed only in the second declaration.
Diagnostic added (coercion between representations):
Example:
type a = | @unboxed A(int) | B({x: int})
type b = | A(int) | B({x: int}) | C
let x: b = (A(3): a :> b)
Before (diagnostic): none; the coerced 3 matches C
After (diagnostic):
Type a is not a subtype of b
Diagnostic modified (unboxed configurations):
Example:
@unboxed type x = One(bool) | Two
type y = One(bool) | Two
Before (diagnostic):
- Variant x is not unboxed.
- Variant y is unboxed.
After (diagnostic):
- Variant x is unboxed.
- Variant y is not unboxed.
Fixes#9038
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t
Signed-off-by: Christoph Knittel <ck@cca.io>
0 commit comments