[前][次][番号順一覧][スレッド一覧]

ruby-changes:63689

From: Benoit <ko1@a...>
Date: Sun, 22 Nov 2020 21:00:32 +0900 (JST)
Subject: [ruby-changes:63689] afb8aba4af (master): [ruby/irb] Add a fallback for check_code_block that does not depend on implementation-private APIs

https://git.ruby-lang.org/ruby.git/commit/?id=afb8aba4af

From afb8aba4af923350cfe0a0ae4b4895d5a837e799 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
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

diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb
index c75d5eb..51efc17 100644
--- a/lib/irb/ruby-lex.rb
+++ b/lib/irb/ruby-lex.rb
@@ -222,11 +222,16 @@ class RubyLex https://github.com/ruby/ruby/blob/trunk/lib/irb/ruby-lex.rb#L222
     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 v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]