www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2218] New: "builtin" typeinfos for arrays of basic types do not inherit TypeInfo_Array

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2218

           Summary: "builtin" typeinfos for arrays of basic types do not
                    inherit TypeInfo_Array
           Product: D
           Version: 1.029
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: tomas famolsen.dk


This is mostly just an inconsistency, but it does break some kinds of code.
Namely dynamically casting for stuff like:

auto ati = cast(TypeInfo_Array)typeid(int[]);
assert(ati !is null); // fails

Trivial to fix, just inherit from TypeInfo_Array instead of TypeInfo in the
internal typeinfo directory.

Probably this issue has been around forever!


-- 
Jul 11 2008
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2218


bugzilla digitalmars.com changed:

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





You shouldn't need to ever cast to TypeInfo_Array. To get the base type of the
array, call next().


-- 
Aug 07 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2218






What is the point of TypeInfo_Array then?


-- 
Aug 08 2008
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2218


dhasenan gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dhasenan gmail.com





*** Bug 2650 has been marked as a duplicate of this bug. ***


-- 
Feb 07 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2218


dhasenan gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |





I understand that I should never have to cast from TypeInfo_Ai to
TypeInfo_Array. That's not what I'm trying to do. I want to cast from TypeInfo
to TypeInfo_Array to see if a type is an array (and then get the value type).

This should be a relatively simple change and would make runtime reflection a
fair bit more powerful -- not in terms of what you can do, perhaps, but
certainly in terms of what information you can gather.

And no, it's *not* an option to try casting to TypeInfo_Ai, then TypeInfo_Aw,
then TypeInfo_Ag, ad nauseum.


-- 
Feb 07 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2218


dhasenan gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID





HAHAHA DISREGARD THAT.

I didn't see that TypeInfo has next().

Still, it's extremely hacky to determine whether a type is an array by checking
whether the tenth character in its classname is 'A'.


-- 
Feb 11 2009