mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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:
parent
5218f17737
commit
afb8aba4af
1 changed files with 7 additions and 2 deletions
|
@ -222,11 +222,16 @@ class RubyLex
|
|||
begin # check if parser error are available
|
||||
verbose, $VERBOSE = $VERBOSE, nil
|
||||
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'
|
||||
JRuby.compile_ir(code)
|
||||
else
|
||||
self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
|
||||
RubyVM::InstructionSequence.compile(inner_code, nil, nil, line_no)
|
||||
catch(:valid) do
|
||||
eval("BEGIN { throw :valid, true }\n#{code}")
|
||||
false
|
||||
end
|
||||
end
|
||||
rescue EncodingError
|
||||
|
|
Loading…
Reference in a new issue