Skip to content

Commit

Permalink
[ruby/prism] Fix lexing of foo! when it's a first thing to parse
Browse files Browse the repository at this point in the history
  • Loading branch information
maxprokopiev authored and matzbot committed Feb 16, 2024
1 parent fbc29ce commit f012ce0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/prism/translation/parser/lexer.rb
Expand Up @@ -289,7 +289,7 @@ def to_a
index += 1
end
when :tFID
if tokens[-1][0] == :kDEF
if !tokens.empty? && tokens[-1][0] == :kDEF
type = :tIDENTIFIER
end
end
Expand Down
1 change: 1 addition & 0 deletions test/prism/fixtures/single_method_call_with_bang.txt
@@ -0,0 +1 @@
foo!
15 changes: 15 additions & 0 deletions test/prism/snapshots/single_method_call_with_bang.txt
@@ -0,0 +1,15 @@
@ ProgramNode (location: (1,0)-(1,4))
├── locals: []
└── statements:
@ StatementsNode (location: (1,0)-(1,4))
└── body: (length: 1)
└── @ CallNode (location: (1,0)-(1,4))
├── flags: ignore_visibility
├── receiver: ∅
├── call_operator_loc: ∅
├── name: :foo!
├── message_loc: (1,0)-(1,4) = "foo!"
├── opening_loc: ∅
├── arguments: ∅
├── closing_loc: ∅
└── block: ∅

0 comments on commit f012ce0

Please sign in to comment.