parse.y: terminator at continued line
* parse.y (here_document): a continuing line is not the terminator. [ruby-core:86283] [Bug #14621] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
491f523ab1
commit
58fbe69a5b
9
parse.y
9
parse.y
@ -6301,7 +6301,13 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bol = was_bol(p);
|
bol = was_bol(p);
|
||||||
if (bol && whole_match_p(p, eos, len, indent)) {
|
/* `heredoc_line_indent == -1` means
|
||||||
|
* - "after an interpolation in the same line", or
|
||||||
|
* - "in a continuing line"
|
||||||
|
*/
|
||||||
|
if (bol &&
|
||||||
|
(p->heredoc_line_indent != -1 || (p->heredoc_line_indent = 0)) &&
|
||||||
|
whole_match_p(p, eos, len, indent)) {
|
||||||
dispatch_heredoc_end(p);
|
dispatch_heredoc_end(p);
|
||||||
heredoc_restore(p, &p->lex.strterm->u.heredoc);
|
heredoc_restore(p, &p->lex.strterm->u.heredoc);
|
||||||
p->lex.strterm = 0;
|
p->lex.strterm = 0;
|
||||||
@ -6371,6 +6377,7 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
|
|||||||
goto restore;
|
goto restore;
|
||||||
}
|
}
|
||||||
if (c != '\n') {
|
if (c != '\n') {
|
||||||
|
if (c == '\\') p->heredoc_line_indent = -1;
|
||||||
flush:
|
flush:
|
||||||
str = STR_NEW3(tok(p), toklen(p), enc, func);
|
str = STR_NEW3(tok(p), toklen(p), enc, func);
|
||||||
flush_str:
|
flush_str:
|
||||||
|
@ -725,6 +725,18 @@ e"
|
|||||||
result = " 1\\\n" " 2\n"
|
result = " 1\\\n" " 2\n"
|
||||||
expected = "1\\\n" "2\n"
|
expected = "1\\\n" "2\n"
|
||||||
assert_dedented_heredoc(expected, result)
|
assert_dedented_heredoc(expected, result)
|
||||||
|
assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /can't find string "TEXT"/)
|
||||||
|
begin;
|
||||||
|
<<-TEXT
|
||||||
|
\
|
||||||
|
TEXT
|
||||||
|
end;
|
||||||
|
assert_syntax_error("#{<<~"begin;"}\n#{<<~'end;'}", /can't find string "TEXT"/)
|
||||||
|
begin;
|
||||||
|
<<~TEXT
|
||||||
|
\
|
||||||
|
TEXT
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_lineno_after_heredoc
|
def test_lineno_after_heredoc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user