summaryrefslogtreecommitdiff
path: root/lib/prism/translation/parser
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2024-02-26 09:35:52 -0500
committergit <svn-admin@ruby-lang.org>2024-02-26 14:48:17 +0000
commit1ce3d9acbf59415f18a2d0ddf4a846cedf17a375 (patch)
tree402eb392dc5482c93e10ab1a4d966a570353093f /lib/prism/translation/parser
parent99d0f687fc4928e06196a695e553acb029d17b61 (diff)
[ruby/prism] Fix xstring heredoc parser translator
https://github.com/ruby/prism/commit/4e0f703975
Diffstat (limited to 'lib/prism/translation/parser')
-rw-r--r--lib/prism/translation/parser/compiler.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb
index 4edbae217d..ab6cea9484 100644
--- a/lib/prism/translation/parser/compiler.rb
+++ b/lib/prism/translation/parser/compiler.rb
@@ -942,7 +942,7 @@ module Prism
# "foo #{bar}"
# ^^^^^^^^^^^^
def visit_interpolated_string_node(node)
- if node.opening&.start_with?("<<")
+ if node.heredoc?
children, closing = visit_heredoc(node)
builder.string_compose(token(node.opening_loc), children, closing)
else
@@ -967,7 +967,7 @@ module Prism
# `foo #{bar}`
# ^^^^^^^^^^^^
def visit_interpolated_x_string_node(node)
- if node.opening.start_with?("<<")
+ if node.heredoc?
children, closing = visit_heredoc(node)
builder.xstring_compose(token(node.opening_loc), children, closing)
else
@@ -1485,8 +1485,8 @@ module Prism
# "foo"
# ^^^^^
def visit_string_node(node)
- if node.opening&.start_with?("<<")
- children, closing = visit_heredoc(InterpolatedStringNode.new(node.send(:source), node.opening_loc, [node.copy(opening_loc: nil, closing_loc: nil, location: node.content_loc)], node.closing_loc, node.location))
+ if node.heredoc?
+ children, closing = visit_heredoc(node.to_interpolated)
builder.string_compose(token(node.opening_loc), children, closing)
elsif node.opening == "?"
builder.character([node.unescaped, srange(node.location)])
@@ -1646,8 +1646,8 @@ module Prism
# `foo`
# ^^^^^
def visit_x_string_node(node)
- if node.opening&.start_with?("<<")
- children, closing = visit_heredoc(InterpolatedXStringNode.new(node.opening_loc, [StringNode.new(0, nil, node.content_loc, nil, node.unescaped, node.content_loc)], node.closing_loc, node.location))
+ if node.heredoc?
+ children, closing = visit_heredoc(node.to_interpolated)
builder.xstring_compose(token(node.opening_loc), children, closing)
else
builder.xstring_compose(