Project

General

Profile

Actions

Bug #6097

closed

Weird constant behavior during inheritance...

Added by ddebernardy (Denis de Bernardy) over 12 years ago. Updated over 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
1.9.3
Backport:
[ruby-core:42979]

Description

class Parent
class Child
def foo
end
end
end
=> nil
class Test < Parent
end
=> nil
Test.const_defined?(:Child)
=> true
class Test
class Child
def bar
end
end
end
=> nil
Test::Child.new.respond_to?(:bar)
=> true
Parent::Child.new.respond_to?(:bar)
=> false # true expected...

Obviously, testing the object_id shows that Parent::Child and Test::Child are not the same class, but is this to be expected?

Updated by fxn (Xavier Noria) over 12 years ago

Once Test::Child gets defined, both Parent and Test have Child among their very constants (and they are different classes). The ancestry chain is not even checked.

Updated by matz (Yukihiro Matsumoto) over 12 years ago

  • Status changed from Open to Rejected

Learn Ruby-way, please.

Actions

Also available in: Atom PDF

Like0
Like0Like0