From afb8aba4af923350cfe0a0ae4b4895d5a837e799 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Thu, 5 Nov 2020 18:08:04 +0100 Subject: [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 --- lib/irb/ruby-lex.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/irb/ruby-lex.rb') diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index c75d5ebf2e..51efc17433 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -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 -- cgit v1.2.3