зеркало из https://github.com/github/ruby.git
[ruby/irb] Add a fallback for check_code_block that does not depend on implementation-private APIs
* Fixes https://github.com/ruby/irb/issues/133 https://github.com/ruby/irb/commit/5eb3ef3293
This commit is contained in:
Родитель
5218f17737
Коммит
afb8aba4af
|
@ -222,11 +222,16 @@ class RubyLex
|
||||||
begin # check if parser error are available
|
begin # check if parser error are available
|
||||||
verbose, $VERBOSE = $VERBOSE, nil
|
verbose, $VERBOSE = $VERBOSE, nil
|
||||||
case RUBY_ENGINE
|
case RUBY_ENGINE
|
||||||
|
when 'ruby'
|
||||||
|
self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
|
||||||
|
RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
|
||||||
|
end
|
||||||
when 'jruby'
|
when 'jruby'
|
||||||
JRuby.compile_ir(code)
|
JRuby.compile_ir(code)
|
||||||
else
|
else
|
||||||
self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
|
catch(:valid) do
|
||||||
RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
|
eval("BEGIN { throw :valid, true }\n#{code}")
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue EncodingError
|
rescue EncodingError
|
||||||
|
|
Загрузка…
Ссылка в новой задаче