summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-06-12 09:44:28 -0400
committerKevin Newton <[email protected]>2024-06-18 21:18:39 -0400
commit24f48382bc3ab62ca0979f1a6879f0d82134abfe (patch)
tree23c9b01c864b6200ec21674872dca2e5686d98ce
parentc93b70cfdde962c24d99253ecf1e2c256d695f67 (diff)
[ruby/prism] (parser) Fix up tokens for empty symbol
https://github.com/ruby/prism/commit/5985ab7687
-rw-r--r--lib/prism/translation/parser/lexer.rb2
-rw-r--r--test/prism/ruby/parser_test.rb3
2 files changed, 2 insertions, 3 deletions
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb
index 9d7caae0ba..8191bd19c5 100644
--- a/lib/prism/translation/parser/lexer.rb
+++ b/lib/prism/translation/parser/lexer.rb
@@ -339,7 +339,7 @@ module Prism
location = Range.new(source_buffer, offset_cache[token.location.start_offset], offset_cache[token.location.start_offset + 1])
end
when :tSYMBEG
- if (next_token = lexed[index][0]) && next_token.type != :STRING_CONTENT && next_token.type != :EMBEXPR_BEGIN && next_token.type != :EMBVAR
+ if (next_token = lexed[index][0]) && next_token.type != :STRING_CONTENT && next_token.type != :EMBEXPR_BEGIN && next_token.type != :EMBVAR && next_token.type != :STRING_END
next_location = token.location.join(next_token.location)
type = :tSYMBOL
value = next_token.value
diff --git a/test/prism/ruby/parser_test.rb b/test/prism/ruby/parser_test.rb
index a5cf919ae5..879e866ef5 100644
--- a/test/prism/ruby/parser_test.rb
+++ b/test/prism/ruby/parser_test.rb
@@ -144,7 +144,6 @@ module Prism
"seattlerb/str_evstr_escape.txt",
"seattlerb/str_newline_hash_line_number.txt",
"seattlerb/str_single_newline.txt",
- "seattlerb/symbol_empty.txt",
"seattlerb/symbols_empty_space.txt",
"seattlerb/TestRubyParserShared.txt",
"unparser/corpus/literal/assignment.txt",
@@ -247,7 +246,7 @@ module Prism
while expected_index < expected_tokens.length
expected_token = expected_tokens[expected_index]
- actual_token = actual_tokens[actual_index]
+ actual_token = actual_tokens.fetch(actual_index, [])
expected_index += 1
actual_index += 1