D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3380 - [tdpl] typeid(obj) should return the dynamic type of the object
Summary: [tdpl] typeid(obj) should return the dynamic type of the object
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-08 19:31 UTC by Andrei Alexandrescu
Modified: 2015-06-09 05:15 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrei Alexandrescu 2009-10-08 19:31:52 UTC
class A {}
class B : A {}

void main() {
   auto a = new A;
   writeln(typeid(a));
}

Currently typeid only applies to a type and consequently returns static type information. This bug report aims at merging classinfo into TypeInfo_class. We need to therefore have typeid accept values.
Comment 1 Don 2009-10-21 03:42:22 UTC
Bug 3346 seems to be the same as this one. When fixed, bug 3345 can probably be closed as well.
Comment 2 Walter Bright 2009-11-20 17:57:12 UTC
I think you meant:

   auto a = new B;
Comment 3 Andrei Alexandrescu 2009-11-20 19:34:52 UTC
(In reply to comment #2)
> I think you meant:
> 
>    auto a = new B;

Sorry. I actually meant:

A a = new B;

meaning that the static type is different from the dynamic type.
Comment 4 Walter Bright 2009-12-06 00:51:52 UTC
Fixed dmd 2.037