[Bug #19736] Recover after unterminated interpolation
This commit is contained in:
parent
49b83b73ef
commit
6be402e172
Notes:
git
2023-06-20 12:25:00 +00:00
6
parse.y
6
parse.y
@ -5331,7 +5331,7 @@ string_content : tSTRING_CONTENT
|
|||||||
$<num>$ = p->heredoc_indent;
|
$<num>$ = p->heredoc_indent;
|
||||||
p->heredoc_indent = 0;
|
p->heredoc_indent = 0;
|
||||||
}
|
}
|
||||||
compstmt tSTRING_DEND
|
compstmt string_dend
|
||||||
{
|
{
|
||||||
COND_POP();
|
COND_POP();
|
||||||
CMDARG_POP();
|
CMDARG_POP();
|
||||||
@ -5348,6 +5348,10 @@ string_content : tSTRING_CONTENT
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
string_dend : tSTRING_DEND
|
||||||
|
| END_OF_INPUT
|
||||||
|
;
|
||||||
|
|
||||||
string_dvar : tGVAR
|
string_dvar : tGVAR
|
||||||
{
|
{
|
||||||
/*%%%*/
|
/*%%%*/
|
||||||
|
@ -264,4 +264,13 @@ world"
|
|||||||
CODE
|
CODE
|
||||||
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_heredoc_unterminated_interpolation
|
||||||
|
code = <<~'HEREDOC'
|
||||||
|
<<A+1
|
||||||
|
#{
|
||||||
|
HEREDOC
|
||||||
|
|
||||||
|
assert_include(Ripper.tokenize(code).join(""), "+1")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1121,6 +1121,15 @@ x = __ENCODING__
|
|||||||
assert_equal v1, v3
|
assert_equal v1, v3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_heredoc_unterminated_interpolation
|
||||||
|
code = <<~'HEREDOC'
|
||||||
|
<<A+1
|
||||||
|
#{
|
||||||
|
HEREDOC
|
||||||
|
|
||||||
|
assert_syntax_error(code, /can't find string "A"/)
|
||||||
|
end
|
||||||
|
|
||||||
def test_unexpected_token_error
|
def test_unexpected_token_error
|
||||||
assert_syntax_error('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', /unexpected/)
|
assert_syntax_error('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', /unexpected/)
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user