From caa2ffc4d77fd057535dd76f12e2f162e26bc65e Mon Sep 17 00:00:00 2001 From: Marek Kaput Date: Wed, 18 Feb 2026 10:24:40 +0100 Subject: [PATCH] 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. --- lib/spitfire.ex | 3 +++ test/spitfire_test.exs | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/spitfire.ex b/lib/spitfire.ex index be54d5c..65ed8c8 100644 --- a/lib/spitfire.ex +++ b/lib/spitfire.ex @@ -1756,6 +1756,9 @@ defmodule Spitfire do :rel_op, :arrow_op, :in_op, + :when_op, + :in_match_op, + :type_op, :xor_op, :ternary_op, :concat_op, diff --git a/test/spitfire_test.exs b/test/spitfire_test.exs index 1dff579..2687777 100644 --- a/test/spitfire_test.exs +++ b/test/spitfire_test.exs @@ -2301,6 +2301,11 @@ defmodule SpitfireTest do assert Spitfire.parse("%e.(){}") == s2q("%e.(){}") assert Spitfire.parse("%e.(1){}") == s2q("%e.(1){}") assert Spitfire.parse("%e.(a, b){}") == s2q("%e.(a, b){}") + + # Ellipsis followed by infix operators that should not be consumed as RHS + assert Spitfire.parse("x...<-y") == s2q("x...<-y") + assert Spitfire.parse("x...::y") == s2q("x...::y") + assert Spitfire.parse("x... when y") == s2q("x... when y") end end