Bug 4741 – typeid() does not return correct type qualifiers for fields

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-08-27T13:36:00Z
Last change time
2013-11-07T08:43:11Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2010-08-27T13:36:15Z
Test case 1: module test; import std.stdio : writeln; struct A { int[] c; } import std.stdio; unittest { const(A) foo; immutable(A) bar; writeln(typeid(foo)); // writes const(test.A) writeln(typeid(bar)); // writes immutable(test.A) writeln(typeid(foo.c)); // writes int[] writeln(typeid(bar.c)); // writes int[] } void main() { } I'm not sure if this is a bug or an enhancement request. I would like the last two calls to writeln to print out this: const(int[]) immutable(int[]) Test case 2: module test; import std.stdio : writeln; class B { int[] c; } import std.stdio; unittest { auto foo = new const(B)(); auto bar = new immutable(B)(); writeln(typeid(foo)); // writes test.B writeln(typeid(bar)); // writes test.B writeln(typeid(foo.c)); // writes int[] writeln(typeid(bar.c)); // writes int[] } void main() { } If a class is involved, the type qualifiers are not printed out at all. So whether or not typeid was designed to return the qualifier, it should behave the same for classes and structs (unless I'm missing something, please correct me if I am).
Comment #1 by andrej.mitrovich — 2013-09-26T07:16:34Z
*** This issue has been marked as a duplicate of issue 7270 ***
Comment #2 by verylonglogin.reg — 2013-11-07T08:43:11Z
This issue has no connection with enhancement request Issue 7270. Here we are dealing with incorrect `TypeInfo` returned by `typeid`. Fields now have correct `TypeInfo`, for classes opened Issue 11468.