Repository navigation
Commit 356ef58
Drop literal arms that a complete payload dispatch runs anyway
A complete payload dispatch with one body runs it unchecked, so a literal arm
with the same body needs no case of its own.
JS modified (literal arm equal to the payload arm):
Example:
@unboxed
type rec t = | @as(null) Null | @as(undefined) Undefined | WhyNotAnotherOne | Point({x: int, y: int})
let plus = (x, y) =>
switch y {
| Null | Undefined => x
| WhyNotAnotherOne => WhyNotAnotherOne
| Point(_) => WhyNotAnotherOne
}
Before (js):
switch (y) {
case null :
case undefined :
return x;
case "WhyNotAnotherOne" :
return "WhyNotAnotherOne";
default:
return "WhyNotAnotherOne";
}
After (js):
if (y == null) {
return x;
} else {
return "WhyNotAnotherOne";
}
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>1 parent e99e3ae commit 356ef58
2 files changed
Lines changed: 17 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
886 | 886 | | |
887 | 887 | | |
888 | 888 | | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
889 | 902 | | |
890 | 903 | | |
891 | 904 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
298 | 294 | | |
299 | 295 | | |
300 | 296 | | |
| |||
0 commit comments