Actions
Bug #21758
openPrism fails to parse heredoc within %Q literal split by another heredoc
Bug #21758:
Prism fails to parse heredoc within %Q literal split by another heredoc
Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0dev (2025-12-02T16:20:43Z master c06c2203ed) +PRISM [x86_64-linux]
Description
Prism fails to parse this code
<<A; %Q
A
#{<<B}
B
Parse error:
a.rb:4: syntax error found (SyntaxError)
2 | A
3 | #{<<B}
> 4 | B
| ^ unexpected constant, expecting end-of-input
B at line 4 appears twice in lex result:
Prism.lex('<<A; %Q
A
#{<<B}
B
').value
#=>
[[HEREDOC_START(1,0)-(1,3)("<<A"), 1],
[HEREDOC_END(2,0)-(3,0)("A\n"), 2],
[SEMICOLON(1,3)-(1,4)(";"), 1],
[STRING_BEGIN(1,5)-(2,0)("%Q\n"), 1],
[EMBEXPR_BEGIN(3,0)-(3,2)("\#{"), 1],
[HEREDOC_START(3,2)-(3,5)("<<B"), 1],
[HEREDOC_END(4,0)-(5,0)("B\n"), 2], # B\n here
[EMBEXPR_END(3,5)-(3,6)("}"), 2],
[STRING_END(3,6)-(4,0)("\n"), 2],
[CONSTANT(4,0)-(4,1)("B"), 2], # Same B again here
[NEWLINE(4,1)-(5,0)("\n"), 1],
[EOF(4,1)-(5,0)("\n"), 1]]
No data to display
Actions