diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-24 00:52:04 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-08-24 00:52:04 +0000 |
commit | 4f03f0cb67b0bf6497ffd4051e872905e3b49ead (patch) | |
tree | 5bebcb6d8c4809603a6964dc63602af5c56d6753 | |
parent | 61920a128a2593f6fb968cfd4928499f0a3e2ed3 (diff) | |
download | ruby-4f03f0cb67b0bf6497ffd4051e872905e3b49ead.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | insns.def | 5 | ||||
-rw-r--r-- | test/ruby/test_variable.rb | 5 |
3 files changed, 16 insertions, 1 deletions
@@ -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 @@ -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 |