Repository navigation
Commit d7ac881
Fold matches of constructors by their runtime literals
Why:
A coercion accepts constructors whose literals are spelled differently
but are the same value, such as `@as(1.)` for `@as(1.0)`, while a match
on a constant constructor was folded by comparing tags structurally, so
the coerced constant missed its arm.
Constant constructors and tagged blocks are now found by the runtime value
of their literal, as the untagged dispatch already does.
JS modified (folded match of a coerced constant):
Example:
type source = | @as(1.) One
type target = | @as(1.0) One | Two | Three | Four
let isOne = (x: target) =>
switch x {
| One => true
| _ => false
}
let r = isOne((One: source :> target))
Before (js): let r = false;
After (js): let r = true;
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 155630c commit d7ac881
3 files changed
Lines changed: 56 additions & 8 deletions
File tree
- compiler/ml
- tests/tests/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
908 | 908 | | |
909 | 909 | | |
910 | 910 | | |
911 | | - | |
| 911 | + | |
| 912 | + | |
912 | 913 | | |
913 | 914 | | |
914 | 915 | | |
915 | | - | |
| 916 | + | |
| 917 | + | |
916 | 918 | | |
917 | 919 | | |
918 | 920 | | |
| |||
940 | 942 | | |
941 | 943 | | |
942 | 944 | | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
943 | 953 | | |
944 | 954 | | |
945 | | - | |
946 | | - | |
947 | | - | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
948 | 958 | | |
949 | | - | |
| 959 | + | |
950 | 960 | | |
951 | 961 | | |
952 | 962 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
10 | 18 | | |
11 | | - | |
12 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
13 | 25 | | |
14 | 26 | | |
15 | 27 | | |
16 | 28 | | |
17 | 29 | | |
18 | 30 | | |
19 | 31 | | |
| 32 | + | |
| 33 | + | |
20 | 34 | | |
21 | 35 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
20 | 39 | | |
21 | 40 | | |
22 | 41 | | |
23 | 42 | | |
24 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
25 | 49 | | |
26 | 50 | | |
27 | 51 | | |
| |||
0 commit comments