Bug 2218 – "builtin" typeinfos for arrays of basic types do not inherit TypeInfo_Array

Status
RESOLVED
Resolution
INVALID
Severity
trivial
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
Linux
Creation time
2008-07-11T14:00:00Z
Last change time
2014-02-24T15:59:49Z
Assigned to
bugzilla
Creator
tomas

Comments

Comment #0 by tomas — 2008-07-11T14:00:10Z
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!
Comment #1 by bugzilla — 2008-08-07T18:26:26Z
You shouldn't need to ever cast to TypeInfo_Array. To get the base type of the array, call next().
Comment #2 by tomas — 2008-08-08T11:19:22Z
What is the point of TypeInfo_Array then?
Comment #3 by dhasenan — 2009-02-07T14:45:41Z
*** Bug 2650 has been marked as a duplicate of this bug. ***
Comment #4 by dhasenan — 2009-02-07T14:53:47Z
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.
Comment #5 by dhasenan — 2009-02-11T18:34:31Z
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'.