Skip to content

Commit 221fe49

Browse files
authored
fix: handle ellipsis before <-, ::, and when (#114)
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 52099ff commit 221fe49

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

lib/spitfire.ex

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

test/spitfire_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,10 @@ defmodule SpitfireTest do
23162316
assert Spitfire.parse("x...\n;//y") == s2q("x...\n;//y")
23172317
assert Spitfire.parse("x...\n;\n//y") == s2q("x...\n;\n//y")
23182318
assert Spitfire.parse("x...\n;\n# comment\n//y") == s2q("x...\n;\n# comment\n//y")
2319+
# Ellipsis followed by infix operators that should not be consumed as RHS
2320+
assert Spitfire.parse("x...<-y") == s2q("x...<-y")
2321+
assert Spitfire.parse("x...::y") == s2q("x...::y")
2322+
assert Spitfire.parse("x... when y") == s2q("x... when y")
23192323
end
23202324
end
23212325

0 commit comments

Comments
 (0)