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

ruby-changes:68031

From: Yusuke <ko1@a...>
Date: Sat, 18 Sep 2021 21:53:08 +0900 (JST)
Subject: [ruby-changes:68031] 1b300789ff (master): ast.c: AST.of against C method should return nil (as Ruby 2.6--3.0)

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

From 1b300789ffc5fda1fcb534d0611ffdb7731e5b9d Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sat, 18 Sep 2021 21:52:18 +0900
Subject: ast.c: AST.of against C method should return nil (as Ruby 2.6--3.0)

---
 ast.c                 | 2 +-
 test/ruby/test_ast.rb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ast.c b/ast.c
index e1c044e..84e5fdc 100644
--- a/ast.c
+++ b/ast.c
@@ -214,7 +214,7 @@ ast_s_of(rb_execution_context_t *ec, VALUE module, VALUE body, VALUE keep_script https://github.com/ruby/ruby/blob/trunk/ast.c#L214
             iseq = rb_method_iseq(body);
         }
         if (!iseq) {
-            rb_raise(rb_eArgError, "cannot get AST for method that is not defined in Ruby");
+            return Qnil;
         }
         if (rb_iseq_from_eval_p(iseq)) {
             rb_raise(rb_eArgError, "cannot get AST for method defined in eval");
diff --git a/test/ruby/test_ast.rb b/test/ruby/test_ast.rb
index 0b5c410..953c843 100644
--- a/test/ruby/test_ast.rb
+++ b/test/ruby/test_ast.rb
@@ -233,7 +233,7 @@ class TestAst < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_ast.rb#L233
 
   def test_of_c_method
     c = Class.new { attr_reader :foo }
-    assert_raise(ArgumentError) { RubyVM::AbstractSyntaxTree.of(c.instance_method(:foo)) }
+    assert_nil(RubyVM::AbstractSyntaxTree.of(c.instance_method(:foo)))
   end
 
   def test_scope_local_variables
-- 
cgit v1.1


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

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