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
Fix null/array guards dropped for untagged variant switch in statement position
When a switch on an untagged variant (e.g. JSON.t) with an Object case was in
statement position (not tail), compile_general_cases would set default=None for
empty default bodies, causing the null/array guard to be silently skipped. This
let null and arrays fall into the typeof "object" branch at runtime.
Two fixes:
- Handle the Some guard, None default case by emitting if (!(guard)) { ... }
- Use the type's block_cases to determine if arrays can appear at runtime,
avoiding unnecessary Array.isArray guards for types without an Array case
Fixes#8251 (comment)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,6 +23,7 @@
23
23
#### :bug: Bug fix
24
24
25
25
- Reanalyze server: invalidate cache and recompute results when config changes in `rescript.json`. https://github.com/rescript-lang/rescript/pull/8262
26
+
- Fix `null` and array values incorrectly matching the `Object` branch when pattern matching on `JSON.t` (or other untagged variants with an `Object` case) in statement position. https://github.com/rescript-lang/rescript/pull/8279
0 commit comments