summaryrefslogtreecommitdiff
path: root/lib/prism
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-06-07 14:52:11 -0400
committergit <[email protected]>2024-06-07 19:46:20 +0000
commit79e9dea8defd74db8d66ec6965cbba55c800f76e (patch)
treec9d907740d6e6d2e57b0b7e83afbf06935acd69b /lib/prism
parentce0a352e34022b46397b5a2712f03bafc1b505ad (diff)
[ruby/prism] Ensure inner heredoc nodes have the correct location
https://github.com/ruby/prism/commit/100340bc6b
Diffstat (limited to 'lib/prism')
-rw-r--r--lib/prism/translation/parser/compiler.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/prism/translation/parser/compiler.rb b/lib/prism/translation/parser/compiler.rb
index 7e4b1d984a..cbec2bb062 100644
--- a/lib/prism/translation/parser/compiler.rb
+++ b/lib/prism/translation/parser/compiler.rb
@@ -2092,7 +2092,12 @@ module Prism
if child.type == :str && child.children.last == ""
# nothing
elsif child.type == :str && children.last && children.last.type == :str && !children.last.children.first.end_with?("\n")
- children.last.children.first << child.children.first
+ appendee = children[-1]
+
+ location = appendee.loc
+ location = location.with_expression(location.expression.join(child.loc.expression))
+
+ children[-1] = appendee.updated(:str, [appendee.children.first << child.children.first], location: location)
else
children << child
end