Commit 7d11a8a
fix(cashc): lower integer
The numeric branch of compileBinaryOp() mapped the binary `*` and `/`
operators to the UNARY OP_2MUL / OP_2DIV (multiply / divide by 2). Since
visitBinaryOp pushes both operands and models the op as binary (pop 2,
push 1), `a * b` compiled to `a b OP_2MUL` — which doubles `b`, leaves `a`
dangling, and silently computes the wrong value. OP_2MUL/OP_2DIV are
enabled in Radiant consensus, so this produced valid-but-wrong scripts
rather than failing loudly. It breaks any contract doing real arithmetic
(e.g. a constant-product AMM); no shipped example multiplied variables, so
it went unnoticed.
Map MUL->OP_MUL and DIV->OP_DIV (both re-enabled in Radiant). Add a
generation regression test and correct the SplitSize fixture, whose baked
ASM (and comment) had encoded the buggy OP_2DIV for `b.length / 2`.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>* and / to OP_MUL/OP_DIV, not OP_2MUL/OP_2DIV1 parent 23e63a9 commit 7d11a8a
3 files changed
Lines changed: 53 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | | - | |
105 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
0 commit comments