summaryrefslogtreecommitdiff
path: root/lib/prism/translation/parser/lexer.rb
diff options
context:
space:
mode:
authorKoichi ITO <koic.ito@gmail.com>2024-03-02 00:43:15 +0900
committergit <svn-admin@ruby-lang.org>2024-03-12 10:45:56 +0000
commit2af6bc26c593951fc591a9d77461d092fab728d8 (patch)
tree751289b0bba03140e42ddb91c3d5493c8b7db840 /lib/prism/translation/parser/lexer.rb
parent76bd586330d98b8a0023ff35c7fa6014ba3a4715 (diff)
[ruby/prism] Fix an AST and token incompatibility for `Prism::Translation::Parser`
Fixes https://github.com/ruby/prism/pull/2515. This PR fixes an AST and token incompatibility between Parser gem and `Prism::Translation::Parser` for string literal with line breaks. https://github.com/ruby/prism/commit/c58466e5bf
Diffstat (limited to 'lib/prism/translation/parser/lexer.rb')
-rw-r--r--lib/prism/translation/parser/lexer.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/prism/translation/parser/lexer.rb b/lib/prism/translation/parser/lexer.rb
index b28273b03f..8bb3084577 100644
--- a/lib/prism/translation/parser/lexer.rb
+++ b/lib/prism/translation/parser/lexer.rb
@@ -281,7 +281,7 @@ module Prism
value = ""
location = Range.new(source_buffer, offset_cache[next_location.start_offset], offset_cache[next_location.end_offset])
index += 1
- elsif ["\"", "'"].include?(value) && (next_token = lexed[index][0]) && next_token.type == :STRING_CONTENT && (next_next_token = lexed[index + 1][0]) && next_next_token.type == :STRING_END
+ elsif ["\"", "'"].include?(value) && (next_token = lexed[index][0]) && next_token.type == :STRING_CONTENT && next_token.value.lines.count <= 1 && (next_next_token = lexed[index + 1][0]) && next_next_token.type == :STRING_END
next_location = token.location.join(next_next_token.location)
type = :tSTRING
value = next_token.value