diff --git a/ChangeLog b/ChangeLog index 1e3c49ee84..54f3d52267 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Wed Aug 24 09:49:10 2011 Koichi Sasada + + * insns.def (defined): fix to checking class variable. + A patch by Magnus Holm . Thanks! + + * test/ruby/test_variable.rb: add a test for above. + Wed Aug 24 08:53:06 2011 Eric Hodel * lib/rdoc: Update to RDoc 3.9.3. Fixes RDoc with `ruby -Ku`. Allows diff --git a/insns.def b/insns.def index 829918c117..0541b344f9 100644 --- a/insns.def +++ b/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)) { diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index 53e00301dc..32b3d61573 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -55,6 +55,11 @@ class TestVariable < Test::Unit::TestCase 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