Repository navigation
Document the rules of untagged variants, with tests pinning them - #8952
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #8952 +/- ##
=======================================
Coverage 81.21% 81.22%
=======================================
Files 457 457
Lines 63853 63853
=======================================
+ Hits 51859 51865 +6
+ Misses 11994 11988 -6 🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-8952 |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a60282c3d9
ℹ️ 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".
The Codex review on #8952 found that intOrStringName(raw(1.5)) was constant-folded to "int", so the test passed without dispatching at run time; the value now goes through the non-inlined id first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q1w9Ff3BgRgQ9bKwBe9TAh Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 49fc4eb77d
ℹ️ 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".
The Codex review on #8952 found that the rule 12 table said no record holds `undefined`, while an `@unboxed` record and a one-field inline record take the answer from their field; the table and rule 12's tests now cover each record shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q1w9Ff3BgRgQ9bKwBe9TAh Signed-off-by: Christoph Knittel <ck@cca.io>
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Why:
The rules of untagged variants (payload kinds, run-time recognition,
well-formedness, option and @notundefined, @as and @tag) are stated once,
each with the code that implements it and a test that pins it, so a
change to them reads as a diff to this statement.
compiler/ml/UntaggedVariants.md states 14 rules, the known bugs observed on
this tree, and the open questions for recognizing payloads by declared class
or typeof kind. untagged_variants_spec_test.res asserts which case each value
lands in; two super_errors fixtures cover the string-case limit and duplicate
literals in a tagged variant.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Cristiano Calcagno <cristianoc@users.noreply.github.com>
The Codex review on #8952 found that intOrStringName(raw(1.5)) was constant-folded to "int", so the test passed without dispatching at run time; the value now goes through the non-inlined id first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q1w9Ff3BgRgQ9bKwBe9TAh Signed-off-by: Christoph Knittel <ck@cca.io>
The Codex review on #8952 found that the rule 12 table said no record holds `undefined`, while an `@unboxed` record and a one-field inline record take the answer from their field; the table and rule 12's tests now cover each record shape. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q1w9Ff3BgRgQ9bKwBe9TAh Signed-off-by: Christoph Knittel <ck@cca.io>
873cf11 to
ccbdf61
Compare
Semantic Diff3 commits · Full page Document the rules of untagged variants, with tests pinning them04e8962 · Cristiano Calcagno with Claude Opus 5.5 · Oct 22, 2026
compiler/ml/UntaggedVariants.md states 14 rules, the known bugs observed on this tree, and the open questions for recognizing payloads by declared class or typeof kind. untagged_variants_spec_test.res asserts which case each value lands in; two super_errors fixtures cover the string-case limit and duplicate literals in a tagged variant. Keep the non-integral number assertion from foldingeb22c7d · Christoph Knittel with Claude Opus 5.5 · Oct 22, 2026 The Codex review on #8952 found that intOrStringName(raw(1.5)) was constant-folded to "int", so the test passed without dispatching at run time; the value now goes through the non-inlined id first. Distinguish record payloads in the option tableccbdf61 · Christoph Knittel with Claude Opus 5.5 · Oct 22, 2026 The Codex review on #8952 found that the rule 12 table said no record holds |
Known bugs filed as issues: #8953 (number literals compared by spelling), #8954 (
Someof a constant@as(undefined)case), #8955 (typed arrays), #8956 (@astags across a signature), and the existing #8938 (overlapping instance classes).compiler/ml/UntaggedVariants.mdstates the rules of untagged variants as they hold on master: 14 numbered rules. Each rule cites the code that implements it, the test that pins it, and the issues that shaped it. The PR changes no compiler behaviour.Rules:
@asliterals;nulland arrays;optionand@notUndefined;@tagand interfaces.Known bugs: five, each reproduced on a fresh build of master with a minimal program and its output.
@asliterals are compared by spelling:@as(1) A | @as(1.0) Bis accepted, andBdispatches asA.Some(U), withUdeclared@as(undefined), compiles toundefined.Filelands in aBlobcase declared before it (Untagged variant with Blob and File cases never matches File when Blob is declared first #8938).I8(Uint8Array…)type-checks and matchesU8.@astags of payload cases are not compared across a signature.The tests do not pin these as correct.
Open questions: nine, for a mechanism that recognizes payloads by a declared class or
typeofkind, such as Declare the runtime class or typeof of types, and annotate the stdlib #8950. They cover unchecked claims, subclasses, overlaps across kinds, the unchecked branch, realms, interfaces and functors, the implied@notUndefined, abbreviations and globals, each with its related issues.A PR that changes these rules updates this document, so the change reads as a diff to it.
Test plan
tests/tests/src/untagged_variants_spec_test.res: 14 tests asserting which case each value lands in. Values pass through an@inline(never)identity so they are not folded.UntaggedAtMostOneString(the string-case limit) andTaggedDuplicateLiteral. The other rejections cite existing fixtures.make test,make checkformat,npx biome checkandyarn changelog:check: pass on a fresh build.🤖 Generated with Claude Code