Repository navigation
Box Some of a constant case represented by undefined - #9008
Conversation
Why:
`Some(U)` with `@as(undefined) U` compiled to plain `undefined` when `U`
was a constant, so it was `None`, while `Some(v)` with `v = U` passed at
run time stayed distinct (#8954).
A constant constructor whose literal is `undefined` is now a none for
`const_some_none_depth`, so `Some` of it is boxed like `Some(None)`. This
holds for untagged and tagged variants alike. The spec's known bug is gone,
and rule 12 states the case.
JS modified:
Example:
@unboxed type u = | @as(undefined) U | V(string)
let x: option<u> = Some(U)
Before (js): let x = undefined;
After (js): let x = Primitive_option.some(undefined);
Fixes: #8954
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>
Changelog
Semantic Diff1 commit · Full page Box Some of a constant case represented by undefinedb5836de · cknitt + Claude · Oct 24, 2026, 06:10 UTC
A constant constructor whose literal is JS modified @unboxed type u = | @as(undefined) U | V(string)
let x: option<u> = Some(U)
-let x = undefined;
+let x = Primitive_option.some(undefined); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9008 +/- ##
=======================================
Coverage 81.29% 81.29%
=======================================
Files 456 456
Lines 63836 63837 +1
=======================================
+ Hits 51893 51894 +1
Misses 11943 11943
🚀 New features to boost your workflow:
|
rescript
@rescript/belt
@rescript/darwin-arm64
@rescript/linux-arm64
@rescript/linux-x64
@rescript/runtime
@rescript/win32-x64
commit: |
|
@codex review |
|
Developer playground preview: https://rescript-lang.github.io/rescript/dev-playground/?version=pr-9008 |
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. |
|
Codex Review: Didn't find any major issues. Nice work! 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". |
Fixes #8954.
Some(U)with@as(undefined) Ucompiled to plainundefinedwhenUwas a constant, so it equalledNone, whileSome(v)withv = Uat run time stayed distinct:The cause was the one the spec conjectured:
Lambda.const_some_none_depthtreated everyConst_constructoras "not a none", including one whose literal isundefined. Such a constructor is now a none, soSomeof it is boxed likeSome(None):let x = Primitive_option.some(undefined);, and the program printsfalse false. Tagged variants with an@as(undefined)case are fixed the same way.UntaggedVariants.md: the known bug is removed, and rule 12 states the case.New test:
untagged_variants_spec_test.resrule 12 checks a constantSome(WUndefined).🤖 Generated with Claude Code
https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t