Commit 192697d
fix: align ellipsis and range-step parsing with Elixir
Update parser semantics around ellipsis and range-step handling to match Elixir behavior for edge cases involving //.
What changed:
- In parse_infix_expression/2, handle infix // as a range-step operator only when the lhs is a range node, producing :..//.
- For non-range lhs, record the same range-step diagnostic intent Elixir uses, instead of silently accepting a generic binary //.
- In parse_ellipsis_op/1, treat :ternary_op as a continuation candidate rather than a standalone-ellipsis stop token, which fixes newline forms like x...\n//y.
- Add a regression test asserting non-range // produces an error path for x...//y.
Why:
The previous behavior diverged from Elixir in two directions: it accepted non-range infix // and parsed x...\n//y as ternary continuation instead of preserving ellipsis unary continuation semantics. This change resolves both at grammar/parse semantics level rather than adding context-specific lookahead hacks.
Special considerations:
- Tokenizer behavior was already aligned with Elixir for these inputs; the fix is parser-only.
- Existing semicolon-separated ellipsis cases remain covered and passing.1 parent 0a01912 commit 192697d
2 files changed
Lines changed: 35 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1404 | 1404 | | |
1405 | 1405 | | |
1406 | 1406 | | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
1407 | 1418 | | |
1408 | 1419 | | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
1409 | 1429 | | |
1410 | 1430 | | |
1411 | 1431 | | |
| |||
2911 | 2931 | | |
2912 | 2932 | | |
2913 | 2933 | | |
2914 | | - | |
| 2934 | + | |
2915 | 2935 | | |
2916 | 2936 | | |
2917 | 2937 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2325 | 2325 | | |
2326 | 2326 | | |
2327 | 2327 | | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
2328 | 2342 | | |
2329 | 2343 | | |
2330 | 2344 | | |
| |||
0 commit comments