Skip to content

Commit 5985ab7

Browse files
committed
(parser) Fix up tokens for empty symbol
1 parent f4c38a3 commit 5985ab7

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

lib/prism/translation/parser/lexer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def to_a
339339
location = Range.new(source_buffer, offset_cache[token.location.start_offset], offset_cache[token.location.start_offset + 1])
340340
end
341341
when :tSYMBEG
342-
if (next_token = lexed[index][0]) && next_token.type != :STRING_CONTENT && next_token.type != :EMBEXPR_BEGIN && next_token.type != :EMBVAR
342+
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
343343
next_location = token.location.join(next_token.location)
344344
type = :tSYMBOL
345345
value = next_token.value

test/prism/ruby/parser_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ class ParserTest < TestCase
144144
"seattlerb/str_evstr_escape.txt",
145145
"seattlerb/str_newline_hash_line_number.txt",
146146
"seattlerb/str_single_newline.txt",
147-
"seattlerb/symbol_empty.txt",
148147
"seattlerb/symbols_empty_space.txt",
149148
"seattlerb/TestRubyParserShared.txt",
150149
"unparser/corpus/literal/assignment.txt",
@@ -247,7 +246,7 @@ def assert_equal_tokens(expected_tokens, actual_tokens)
247246

248247
while expected_index < expected_tokens.length
249248
expected_token = expected_tokens[expected_index]
250-
actual_token = actual_tokens[actual_index]
249+
actual_token = actual_tokens.fetch(actual_index, [])
251250

252251
expected_index += 1
253252
actual_index += 1

0 commit comments

Comments
 (0)