www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4741] New: typeid() does not return correct type qualifiers for fields

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich 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: -------
Aug 27 2010
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4741


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-09-26
07:16:34 PDT ---
*** This issue has been marked as a duplicate of issue 7270 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 26 2013