[ruby/prism] Fix lexing of foo! when it's a first thing to parse

https://github.com/ruby/prism/commit/7597aca76a
This commit is contained in:
Max Prokopiev 2024-02-16 14:43:35 +01:00 committed by git
parent fbc29ce032
commit f012ce0d18
3 changed files with 17 additions and 1 deletions

View File

@ -289,7 +289,7 @@ module Prism
index += 1
end
when :tFID
if tokens[-1][0] == :kDEF
if !tokens.empty? && tokens[-1][0] == :kDEF
type = :tIDENTIFIER
end
end

View File

@ -0,0 +1 @@
foo!

View File

@ -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: ∅