[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;
|
||||
p->heredoc_indent = 0;
|
||||
}
|
||||
compstmt tSTRING_DEND
|
||||
compstmt string_dend
|
||||
{
|
||||
COND_POP();
|
||||
CMDARG_POP();
|
||||
@ -5348,6 +5348,10 @@ string_content : tSTRING_CONTENT
|
||||
}
|
||||
;
|
||||
|
||||
string_dend : tSTRING_DEND
|
||||
| END_OF_INPUT
|
||||
;
|
||||
|
||||
string_dvar : tGVAR
|
||||
{
|
||||
/*%%%*/
|
||||
|
@ -264,4 +264,13 @@ world"
|
||||
CODE
|
||||
assert_equal(code, Ripper.tokenize(code).join(""), bug)
|
||||
end
|
||||
|
||||
def test_heredoc_unterminated_interpolation
|
||||
code = <<~'HEREDOC'
|
||||
<<A+1
|
||||
#{
|
||||
HEREDOC
|
||||
|
||||
assert_include(Ripper.tokenize(code).join(""), "+1")
|
||||
end
|
||||
end
|
||||
|
@ -1121,6 +1121,15 @@ x = __ENCODING__
|
||||
assert_equal v1, v3
|
||||
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
|
||||
assert_syntax_error('"x"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', /unexpected/)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user