Repository navigation
Fix a bool payload beside a bool literal in an incomplete match - #9036
Conversation
Why:
`typeof x === "boolean" && x !== b` was simplified to the constant `!b`,
not to `x === !b` as its doc comment says. A match on a bool payload
beside a bool literal case produces this conjunction, so it never or
always took the payload arm (#9035).
JS modified (bool payload beside a bool literal):
Example:
@unboxed type t = | @as(true) LitTrue | AnyBool(bool) | AnyInt(int)
let f = (v: t) =>
switch v {
| AnyBool(_) => "bool"
| _ => "other"
}
Before (js):
function f(v) {
return "other";
}
After (js):
function f(v) {
if (v !== false) {
return "other";
} else {
return "bool";
}
}
Fixes #9035
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🐛 Bug fix
Semantic Diff1 commit · Full page Simplify a boolean other than one to the other boolean717d266 · cknitt + Claude · Oct 25, 2026, 06:02 UTC
JS modified (bool payload beside a bool literal) @unboxed type t = | @as(true) LitTrue | AnyBool(bool) | AnyInt(int)
let f = (v: t) =>
switch v {
| AnyBool(_) => "bool"
| _ => "other"
}
function f(v) {
- return "other";
+ if (v !== false) {
+ return "other";
+ } else {
+ return "bool";
+ }
}Fixes #9035 |
|
@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. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! 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". |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9036 +/- ##
=======================================
Coverage 81.32% 81.33%
=======================================
Files 456 456
Lines 64042 64042
=======================================
+ Hits 52082 52086 +4
+ Misses 11960 11956 -4
🚀 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-9036 |
|
Codex Review: Didn't find any major issues. Delightful! 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". |
cristianoc
left a comment
There was a problem hiding this comment.
Noticing the pr description is low quality.
While the commit description is medium quality.
We should look into improving the text of PR descriptions.
Fixes #9035.
Js_exp_make.simplify_and_rewrotetypeof x === "boolean" && x !== bto the constant!b. Its doc comment says the result isx === !b, which is the correct one. A match on a bool payload of an untagged variant, beside a bool literal case, produces exactly this conjunction. So in a match that doesn't name every case, the payload arm was never taken (@as(true)) or always taken (@as(false)).New test:
untagged_bool_payload_test.rescovers a bool payload beside@as(true)and beside@as(false), with values that aren't folded at compile time.Found by a review of the untagged variant work (#8950).
🤖 Generated with Claude Code
https://claude.ai/code/session_01CMkrYaktctdKc4M41WF36t