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 a56f60f
Browse filesBrowse the repository at this point in the historyBrowse files
* Make @unboxed apply to a whole variant only
Why:
`@unboxed` on a single constructor made that constructor untagged and
left the others tagged. Such mixed variants missed the checks of
untagged ones (#9020) and interface and coercion checks (#9038), and
their matches crashed or picked the wrong case. Public code uses the
attribute on every payload constructor or on the only one, which the
type-level `@unboxed` says, but no code mixes tagged and untagged cases.
`@unboxed` on a constructor is an error that says to write it on the type.
The layout of a variant is untagged exactly when its type is `@unboxed`, so
`check_invariant` no longer considers tagged and untagged blocks together,
the type's `@unboxed` is no longer copied onto constructors, and
`process_untagged`, a twin of `has_untagged`, is gone.
Diagnostic added (@unboxed on a constructor):
Example:
type t = | @unboxed A(int) | B({x: int}) | C
Before (diagnostic): none; `A(3)` is `3` and `B` is `{TAG: "B", x: 1}`
After (diagnostic):
@unboxed applies to a whole variant: write it on the type, as in `@unboxed type t = ...`, instead of on constructor A.
Diagnostic added (@unboxed on a single-field inline record constructor):
Example:
type t = | @unboxed A({x: int})
Before (diagnostic): none; `A({x: 1})` is `{x: 1}`
After (diagnostic):
@unboxed applies to a whole variant: write it on the type, as in `@unboxed type t = ...`, instead of on constructor A. For a constructor whose payload is an inline record with one field, `@unboxed type t = A({...})` makes the value that field. To keep the record object, give the record type a name: `@unboxed type t = A(r)`.
Breaking: `@unboxed` on a constructor no longer compiles. Moving it to the
type keeps the representation, except for a constructor whose payload is an
inline record with one field, whose value becomes the field; a named record
type keeps the object.
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>
* Name the unboxed variant correctly in the coercion error
The error for a coercion between variants with different `@unboxed`
configurations said that the wrong one was unboxed.
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.
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>
---------
Signed-off-by: Christoph Knittel <ck@cca.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
-`@unboxed` applies to a whole variant and can no longer be written on a constructor. Write `@unboxed type t = ...` instead. A constructor whose payload is an inline record with one field became that record object, while `@unboxed` on its type makes the value the field: give the record type a name to keep the object.
0 commit comments