Skip to content

Commit 5931491

Browse files
kddnewtonmatzbot
authored andcommitted
[ruby/prism] Nested heredoc with newline terminator
When you have a heredoc interpolated into another heredoc where the inner heredoc is terminated by a newline, you need to avoid adding the newline character a second time. ruby/prism@8eeb5f358b
1 parent 268cbb2 commit 5931491

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

prism/prism.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12031,7 +12031,10 @@ parser_lex(pm_parser_t *parser) {
1203112031
// string content.
1203212032
if (heredoc_lex_mode->indent == PM_HEREDOC_INDENT_TILDE) {
1203312033
const uint8_t *end = parser->current.end;
12034-
pm_newline_list_append(&parser->newline_list, end);
12034+
12035+
if (parser->heredoc_end == NULL) {
12036+
pm_newline_list_append(&parser->newline_list, end);
12037+
}
1203512038

1203612039
// Here we want the buffer to only
1203712040
// include up to the backslash.

0 commit comments

Comments
 (0)