зеркало из https://github.com/github/ruby.git
merge revision(s) 97449338d6cb42d9dd7c9ca61550616e7e6b6ef6: [Backport #20649]
[Bug #20649] Allow `nil` as 2nd argument of `assign_error` Fallback to the last token element in that case, for the backward compatibilities.
This commit is contained in:
Родитель
6a4e79533b
Коммит
b210c86a02
|
@ -242,7 +242,12 @@ class Ripper
|
|||
end
|
||||
|
||||
def on_error2(mesg, elem)
|
||||
@errors.push Elem.new(elem.pos, __callee__, elem.tok, elem.state, mesg)
|
||||
if elem
|
||||
elem = Elem.new(elem.pos, __callee__, elem.tok, elem.state, mesg)
|
||||
else
|
||||
elem = Elem.new([lineno(), column()], __callee__, token(), state(), mesg)
|
||||
end
|
||||
@errors.push elem
|
||||
end
|
||||
PARSER_EVENTS.grep(/_error\z/) do |e|
|
||||
arity = PARSER_EVENT_TABLE.fetch(e)
|
||||
|
|
|
@ -53,6 +53,8 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
|
|||
Ripper.tokenize("1 .foo\n")
|
||||
assert_equal ["1", "\n", " ", ".", "foo", "\n"],
|
||||
Ripper.tokenize("1\n .foo\n")
|
||||
assert_equal ["def", " ", "f", ";", " ", "(", "x", ")", "::", "A", " ", "="],
|
||||
Ripper.tokenize("def f; (x)::A =")
|
||||
end
|
||||
|
||||
def test_lex
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 4
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 96
|
||||
#define RUBY_PATCHLEVEL 97
|
||||
|
||||
#include "ruby/version.h"
|
||||
#include "ruby/internal/abi.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче