Commit f49ac9a
committed
fix(parser): parenthesized sub-expressions in arithmetic (trim_outer shadowing bug)
parse_expr trimmed outer parens in two statements:
let start = trim_outer(..).0;
let end = trim_outer(.., start, ..).1; // uses the already-incremented start
so the second call saw a range no longer starting with '(' and left the closing ')'
in range -> every parenthesized expression became Expr::Unknown (RS0015). Collapse to
a single tuple destructure. Now (a+b), (a+b)*c, a*(b+c), ((a+b)*c)-a all parse+eval.
Regression fixture: tests/fixtures/pass/paren-grouping-arithmetic.rss. cargo test green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent d20dd60 commit f49ac9a
3 files changed
Lines changed: 18 additions & 4 deletions
File tree
- .claude
- crates/rsscript
- src/syntax
- tests/fixtures/pass
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2217 | 2217 | | |
2218 | 2218 | | |
2219 | 2219 | | |
2220 | | - | |
2221 | | - | |
| 2220 | + | |
2222 | 2221 | | |
2223 | 2222 | | |
2224 | 2223 | | |
| |||
2441 | 2440 | | |
2442 | 2441 | | |
2443 | 2442 | | |
2444 | | - | |
2445 | | - | |
| 2443 | + | |
2446 | 2444 | | |
2447 | 2445 | | |
2448 | 2446 | | |
| |||
Lines changed: 15 additions & 0 deletions
| 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 | + | |
0 commit comments