Permalink
Browse files

* insns.def (defined): fix to checking class variable.

  A patch by Magnus Holm <judofyr@gmail.com>.  Thanks!
* test/ruby/test_variable.rb: add a test for above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 61920a1 commit 4f03f0cb67b0bf6497ffd4051e872905e3b49ead @ko1 ko1 committed Aug 24, 2011
Showing with 16 additions and 1 deletion.
  1. +7 −0 ChangeLog
  2. +4 −1 insns.def
  3. +5 −0 test/ruby/test_variable.rb
View
7 ChangeLog
@@ -1,3 +1,10 @@
+Wed Aug 24 09:49:10 2011 Koichi Sasada <ko1@atdot.net>
+
+ * insns.def (defined): fix to checking class variable.
+ A patch by Magnus Holm <judofyr@gmail.com>. Thanks!
+
+ * test/ruby/test_variable.rb: add a test for above.
+
Wed Aug 24 08:53:06 2011 Eric Hodel <drbrain@segment7.net>
* lib/rdoc: Update to RDoc 3.9.3. Fixes RDoc with `ruby -Ku`. Allows
View
5 insns.def
@@ -773,11 +773,14 @@ defined
}
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)) {
View
5 test/ruby/test_variable.rb
@@ -55,6 +55,11 @@ def test_variable
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

0 comments on commit 4f03f0c

Please sign in to comment.