From 79e9dea8defd74db8d66ec6965cbba55c800f76e Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Fri, 7 Jun 2024 14:52:11 -0400 Subject: [ruby/prism] Ensure inner heredoc nodes have the correct location https://github.com/ruby/prism/commit/100340bc6b --- lib/prism/translation/parser/compiler.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') 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 -- cgit v1.2.3