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

ruby-changes:40917

From: ko1 <ko1@a...>
Date: Wed, 9 Dec 2015 16:16:08 +0900 (JST)
Subject: [ruby-changes:40917] ko1:r52996 (trunk): * vm.c (rb_vm_cref_in_context): Module#define_method in non-class

ko1	2015-12-09 16:15:48 +0900 (Wed, 09 Dec 2015)

  New Revision: 52996

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52996

  Log:
    * vm.c (rb_vm_cref_in_context): Module#define_method in non-class
      expression should be public.
      [Bug #11754]
    
    * test/ruby/test_method.rb: add a test.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_method.rb
    trunk/vm.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52995)
+++ ChangeLog	(revision 52996)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec  9 16:10:37 2015  Koichi Sasada  <ko1@a...>
+
+	* vm.c (rb_vm_cref_in_context): Module#define_method in non-class
+	  expression should be public.
+	  [Bug #11754]
+
+	* test/ruby/test_method.rb: add a test.
+
 Wed Dec  9 15:48:12 2015  Nobuyoshi Nakada  <nobu@r...>
 
 	* regcomp.c (onig_chain_link_add): use atomic operation instead of
Index: vm.c
===================================================================
--- vm.c	(revision 52995)
+++ vm.c	(revision 52996)
@@ -1226,6 +1226,7 @@ rb_vm_cref_in_context(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm.c#L1226
     const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
     const rb_cref_t *cref;
     if (cfp->self != self) return NULL;
+    if (!vm_env_cref_by_cref(cfp->ep)) return NULL;
     cref = rb_vm_get_cref(cfp->ep);
     if (CREF_CLASS(cref) != cbase) return NULL;
     return cref;
Index: test/ruby/test_method.rb
===================================================================
--- test/ruby/test_method.rb	(revision 52995)
+++ test/ruby/test_method.rb	(revision 52996)
@@ -924,6 +924,8 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L924
     def m1
       def m2
       end
+
+      self.class.send(:define_method, :m3){} # [Bug #11754]
     end
     private
   end
@@ -933,7 +935,7 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L935
     assert_equal([].sort, MethodInMethodClass.private_instance_methods(false).sort)
 
     MethodInMethodClass.new.m1
-    assert_equal([:m1, :m2].sort, MethodInMethodClass.public_instance_methods(false).sort)
+    assert_equal([:m1, :m2, :m3].sort, MethodInMethodClass.public_instance_methods(false).sort)
     assert_equal([].sort, MethodInMethodClass.private_instance_methods(false).sort)
   end
 end

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

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