[Bug #19399] Parsing invalid heredoc inside block parameter

Although this is of course invalid as Ruby code, allow to just parse
and tokenize.
This commit is contained in:
Nobuyoshi Nakada 2023-02-02 10:52:38 +09:00
Родитель f499c81b01
Коммит fad48fefe1
2 изменённых файлов: 13 добавлений и 1 удалений

Просмотреть файл

@ -228,7 +228,7 @@ class Ripper
def on_heredoc_end(tok)
@buf.push Elem.new([lineno(), column()], __callee__, tok, state())
@buf = @stack.pop
@buf = @stack.pop unless @stack.empty?
end
def _push_token(tok)

Просмотреть файл

@ -252,4 +252,16 @@ world"
]
assert_equal(code, Ripper.tokenize(code).join(""), bug)
end
def test_heredoc_inside_block_param
bug = '[Bug #19399]'
code = <<~CODE
a do |b
<<-C
C
|
end
CODE
assert_equal(code, Ripper.tokenize(code).join(""), bug)
end
end