diff options
| author | Max Prokopiev <maxprokopiev@github.com> | 2024-02-16 14:43:35 +0100 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-02-16 14:08:56 +0000 |
| commit | f012ce0d18b19a8dfc815498108b9b5fdde26b46 (patch) | |
| tree | e3ab256625f897656b45098a3316af6987eed402 | |
| parent | fbc29ce032ef18887b935b48da1b94863ca407d9 (diff) | |
[ruby/prism] Fix lexing of `foo!` when it's a first thing to parse
https://github.com/ruby/prism/commit/7597aca76a
| -rw-r--r-- | lib/prism/translation/parser/lexer.rb | 2 | ||||
| -rw-r--r-- | test/prism/fixtures/single_method_call_with_bang.txt | 1 | ||||
| -rw-r--r-- | test/prism/snapshots/single_method_call_with_bang.txt | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb index 6d3321b945..5c993cfab8 100644 --- a/lib/prism/translation/parser/lexer.rb +++ b/lib/prism/translation/parser/lexer.rb @@ -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 diff --git a/test/prism/fixtures/single_method_call_with_bang.txt b/test/prism/fixtures/single_method_call_with_bang.txt new file mode 100644 index 0000000000..929efb3053 --- /dev/null +++ b/test/prism/fixtures/single_method_call_with_bang.txt @@ -0,0 +1 @@ +foo! diff --git a/test/prism/snapshots/single_method_call_with_bang.txt b/test/prism/snapshots/single_method_call_with_bang.txt new file mode 100644 index 0000000000..4c68e0adac --- /dev/null +++ b/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: ∅ |
