1
0
Fork 0
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:
Benoit Daloze 2020-11-05 18:08:04 +01:00 committed by aycabta
parent 5218f17737
commit afb8aba4af

View file

@ -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