зеркало из https://github.com/github/ruby.git
ripper: fix a bug of Ripper::Lexer with syntax error and heredoc [Bug #17644]
This commit is contained in:
Родитель
7b9476fbfa
Коммит
5de38c41ae
|
@ -136,7 +136,7 @@ class Ripper
|
|||
end
|
||||
@buf.flatten!
|
||||
unless (result = @buf).empty?
|
||||
result.concat(@buf) until (@buf = []; super(); @buf.empty?)
|
||||
result.concat(@buf) until (@buf = []; super(); @buf.flatten!; @buf.empty?)
|
||||
end
|
||||
result
|
||||
end
|
||||
|
|
|
@ -216,4 +216,16 @@ class TestRipper::Lexer < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_lex_with_syntax_error_and_heredo
|
||||
bug = '[Bug #17644]'
|
||||
s = <<~EOF
|
||||
foo
|
||||
end
|
||||
<<~EOS
|
||||
bar
|
||||
EOS
|
||||
EOF
|
||||
assert_equal([[5, 0], :on_heredoc_end, "EOS\n", state(:EXPR_BEG)], Ripper.lex(s).last, bug)
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче