mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ripper: fix a bug of Ripper::Lexer with syntax error and heredoc [Bug #17644]
This commit is contained in:
parent
7b9476fbfa
commit
5de38c41ae
2 changed files with 13 additions and 1 deletions
|
|
@ -136,7 +136,7 @@ class Ripper
|
||||||
end
|
end
|
||||||
@buf.flatten!
|
@buf.flatten!
|
||||||
unless (result = @buf).empty?
|
unless (result = @buf).empty?
|
||||||
result.concat(@buf) until (@buf = []; super(); @buf.empty?)
|
result.concat(@buf) until (@buf = []; super(); @buf.flatten!; @buf.empty?)
|
||||||
end
|
end
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -216,4 +216,16 @@ class TestRipper::Lexer < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue