[Issue 4741] New: typeid() does not return correct type qualifiers for fields
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Aug 27 13:36:27 PDT 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4741
Summary: typeid() does not return correct type qualifiers for
fields
Product: D
Version: D2
Platform: Other
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2010-08-27 13:36:15 PDT ---
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).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list