Skip to content

Commit 87d928c

Browse files
committed
Fix right assignment token management
1 parent 12b1298 commit 87d928c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/syntax_tree/parser.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,12 @@ def on_case(value, consequent)
910910
location: keyword.location.to(consequent.location)
911911
)
912912
else
913-
operator = find_token(Kw, "in", consume: false) || find_token(Op, "=>")
913+
operator =
914+
if (keyword = find_token(Kw, "in", consume: false))
915+
tokens.delete(keyword)
916+
else
917+
find_token(Op, "=>")
918+
end
914919

915920
RAssign.new(
916921
value: value,

test/fixtures/rassign.rb

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@
2020
ConstantConstantConstant,
2121
ConstantConstantConstant
2222
]
23+
%
24+
a in Integer
25+
b => [Integer => c]

0 commit comments

Comments
 (0)