Skip to content

Commit 065ec79

Browse files
committed
fix: handle ellipsis before <-, ::, and when
Ellipsis standalone detection used is_binary_op?/1, but that set did not include in_match_op, type_op, or when_op. As a result, expressions like x...<-y and x...::y attempted to parse <-/:: as an ellipsis RHS prefix and failed with unknown token errors. Extend @binary_op_types with when_op, in_match_op, and type_op so parse_ellipsis_op/1 keeps ... standalone before those operators, matching Elixir AST behavior. Add regression assertions in the existing property regression block for x...<-y, x...::y, and x... when y alongside the newline ternary case.
1 parent ec594dd commit 065ec79

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/spitfire.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,9 @@ defmodule Spitfire do
17561756
:rel_op,
17571757
:arrow_op,
17581758
:in_op,
1759+
:when_op,
1760+
:in_match_op,
1761+
:type_op,
17591762
:xor_op,
17601763
:ternary_op,
17611764
:concat_op,

test/spitfire_test.exs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,6 +2300,11 @@ defmodule SpitfireTest do
23002300
assert Spitfire.parse("%e.(){}") == s2q("%e.(){}")
23012301
assert Spitfire.parse("%e.(1){}") == s2q("%e.(1){}")
23022302
assert Spitfire.parse("%e.(a, b){}") == s2q("%e.(a, b){}")
2303+
2304+
# Ellipsis followed by infix operators that should not be consumed as RHS
2305+
assert Spitfire.parse("x...<-y") == s2q("x...<-y")
2306+
assert Spitfire.parse("x...::y") == s2q("x...::y")
2307+
assert Spitfire.parse("x... when y") == s2q("x... when y")
23032308
end
23042309
end
23052310

0 commit comments

Comments
 (0)