mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* variable.c (rb_const_defined_0): fix autoloading base.
[ruby-core:35509] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e6a4a8018d
commit
0e3822c1e2
3 changed files with 24 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Mar 24 23:05:42 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* variable.c (rb_const_defined_0): fix autoloading base.
|
||||
[ruby-core:35509]
|
||||
|
||||
Thu Mar 24 22:48:43 2011 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/sdbm/_sdbm.c: parenthesize macro arguments.
|
||||
|
|
|
@ -85,4 +85,22 @@ class TestDefined < Test::Unit::TestCase
|
|||
assert_equal 'global-variable', defined?($1)
|
||||
assert_equal nil, defined?($2)
|
||||
end
|
||||
|
||||
def test_autoloaded_subclass
|
||||
bug = "[ruby-core:35509]"
|
||||
|
||||
klass = Class.new do
|
||||
autoload(:A, "a")
|
||||
end
|
||||
x = klass.new
|
||||
class << x
|
||||
def a?; defined?(A); end
|
||||
end
|
||||
assert_equal("constant", x.a?, bug)
|
||||
|
||||
klass = Class.new(klass) do
|
||||
def a?; defined?(A); end
|
||||
end
|
||||
assert_equal("constant", klass.new.a?, bug)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1816,7 +1816,7 @@ rb_const_defined_0(VALUE klass, ID id, int exclude, int recurse, int visibility)
|
|||
if (visibility && ce->flag == CONST_PRIVATE) {
|
||||
return (int)Qfalse;
|
||||
}
|
||||
if (ce->value == Qundef && !autoload_node((VALUE)klass, id, 0))
|
||||
if (ce->value == Qundef && !autoload_node(tmp, id, 0))
|
||||
return (int)Qfalse;
|
||||
return (int)Qtrue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue