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

ruby-changes:20996

From: ko1 <ko1@a...>
Date: Wed, 24 Aug 2011 09:53:20 +0900 (JST)
Subject: [ruby-changes:20996] ko1:r33045 (trunk): * insns.def (defined): fix to checking class variable.

ko1	2011-08-24 09:52:04 +0900 (Wed, 24 Aug 2011)

  New Revision: 33045

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

  Log:
    * insns.def (defined): fix to checking class variable.
      A patch by Magnus Holm <judofyr@g...>.  Thanks!
    * test/ruby/test_variable.rb: add a test for above.

  Modified files:
    trunk/ChangeLog
    trunk/insns.def
    trunk/test/ruby/test_variable.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33044)
+++ ChangeLog	(revision 33045)
@@ -1,3 +1,10 @@
+Wed Aug 24 09:49:10 2011  Koichi Sasada  <ko1@a...>
+
+	* insns.def (defined): fix to checking class variable.
+	  A patch by Magnus Holm <judofyr@g...>.  Thanks!
+
+	* test/ruby/test_variable.rb: add a test for above.
+
 Wed Aug 24 08:53:06 2011  Eric Hodel  <drbrain@s...>
 
 	* lib/rdoc:  Update to RDoc 3.9.3.  Fixes RDoc with `ruby -Ku`.  Allows
Index: insns.def
===================================================================
--- insns.def	(revision 33044)
+++ insns.def	(revision 33045)
@@ -773,11 +773,14 @@
 	}
 	break;
       case DEFINED_CVAR:
-	klass = vm_get_cbase(GET_ISEQ(), GET_LFP(), GET_DFP());
+	{
+	NODE *cref = vm_get_cref(GET_ISEQ(), GET_LFP(), GET_DFP());
+	klass = vm_get_cvar_base(cref);
 	if (rb_cvar_defined(klass, SYM2ID(obj))) {
 	    expr_type = "class variable";
 	}
 	break;
+	}
       case DEFINED_CONST:
 	klass = v;
 	if (vm_get_ev_const(th, GET_ISEQ(), klass, SYM2ID(obj), 1)) {
Index: test/ruby/test_variable.rb
===================================================================
--- test/ruby/test_variable.rb	(revision 33044)
+++ test/ruby/test_variable.rb	(revision 33045)
@@ -55,6 +55,11 @@
     assert_equal("Cronus", atlas.ruler0)
     assert_equal("Zeus", atlas.ruler3)
     assert_equal("Cronus", atlas.ruler4)
+    assert_nothing_raised do
+      class << Gods
+        defined?(@@rule) && @@rule
+      end
+    end
   end
 
   def test_local_variables

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

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