Skip to content

[12.x] Deprecate @unboxed on a variant constructor - #9049

Merged
cknitt merged 3 commits into
maintenance/12.xfrom
unboxed-constructor-deprecation-12
Oct 26, 2026
Merged

cknitt merged 3 commits into
maintenance/12.xfrom
unboxed-constructor-deprecation-12

Conversation

@cknitt

@cknitt cknitt commented Oct 26, 2026

Copy link
Copy Markdown
Member

v13 rejects @unboxed on a variant constructor (#9040): @unboxed applies to a whole variant. This deprecates it in 12.x so users hear about it before upgrading.

@unboxed written on a constructor now gives warning 3, with one of two messages:

  • on a type without @unboxed: "@unboxed on constructor Text is deprecated and will be an error in v13, where @unboxed applies to a whole variant: write it on the type, as in @unboxed type t = ...."
  • on an @unboxed type: "… The type is already @unboxed, so remove it from the constructor."

The check reads the constructor's attributes as written, before the type's attributes are copied to its constructors, so a type-level @unboxed does not warn. A @warning("-3") on the constructor silences it.

New test: super_errors/fixtures/unboxed_on_constructor_deprecated.res.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t

cknitt and others added 2 commits October 26, 2026 05:53
Why:
    v13 rejects @unboxed on a constructor (#9040): @unboxed applies to a
    whole variant. 12.x users should hear about it before upgrading.

`@unboxed` written on a constructor warns (warning 3), before the type's
attributes are copied to its constructors, so a type-level `@unboxed` does
not warn.

Diagnostic added (@unboxed on a constructor):
Example:
    type mixed = | @unboxed Text(string) | Count(int)
    @unboxed
    type whole = | @unboxed Name(string) | Age(int)
Before (diagnostic): none
After (diagnostic):
    Warning number 3
    deprecated: @unboxed on constructor Text is deprecated and will be an
    error in v13, where @unboxed applies to a whole variant: write it on the
    type, as in `@unboxed type t = ...`.
    Warning number 3
    deprecated: @unboxed on constructor Name is deprecated and will be an
    error in v13. The type is already @unboxed, so remove it from the
    constructor.

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>
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>
@cknitt

cknitt commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T06:13:15.089753Z 6786938 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e73b906af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread compiler/ml/typedecl.ml
Why:
    A variant spread copies the source constructors with their attributes,
    including the source type's `@unboxed`, so the spread site warned about
    an annotation the user never wrote, or repeated the source's warning.

The deprecation now skips constructors marked as coming from a spread;
`@unboxed` written on a constructor is reported once, where it is written.

Diagnostic removed (@unboxed reported at a spread):
Example:
    @unboxed
    type a = A(string)
    @unboxed
    type b = | ...a | B(int)
Before (diagnostic):
    Warning number 3
    1:1-8
    deprecated: @unboxed on constructor A is deprecated and will be an
    error in v13. The type is already @unboxed, so remove it from the
    constructor.
After (diagnostic): none

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>
@cknitt

cknitt commented Oct 26, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 6786938b41

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cknitt
cknitt requested a review from fhammerschmidt October 26, 2026 06:14
@cknitt
cknitt marked this pull request as ready for review October 26, 2026 06:14
@cknitt
cknitt enabled auto-merge (squash) October 26, 2026 06:14
@cknitt
cknitt merged commit 5ee4c56 into maintenance/12.x Oct 26, 2026
7 of 8 checks passed
@cknitt
cknitt deleted the unboxed-constructor-deprecation-12 branch October 26, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants