diff options
-rw-r--r-- | parse.y | 10 | ||||
-rw-r--r-- | test/ruby/test_syntax.rb | 6 |
2 files changed, 15 insertions, 1 deletions
@@ -5642,7 +5642,14 @@ tokadd_string(struct parser_params *p, switch (c) { case '\n': if (func & STR_FUNC_QWORDS) break; - if (func & STR_FUNC_EXPAND) continue; + if (func & STR_FUNC_EXPAND) { + if (!(func & STR_FUNC_INDENT) || (p->heredoc_indent < 0)) + continue; + if (c == term) { + c = '\\'; + goto terminate; + } + } tokadd(p, '\\'); break; @@ -5723,6 +5730,7 @@ tokadd_string(struct parser_params *p, } tokadd(p, c); } + terminate: if (enc) *encp = enc; return c; } diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index d426f835ae..283bac3f5f 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -721,6 +721,12 @@ e" assert_dedented_heredoc(expected, result) end + def test_dedented_heredoc_continued_line + result = " 1\\\n" " 2\n" + expected = "1\\\n" "2\n" + assert_dedented_heredoc(expected, result) + end + def test_lineno_after_heredoc bug7559 = '[ruby-dev:46737]' expected, _, actual = __LINE__, <<eom, __LINE__ |