[Issue 12303] New: Different `TypeInfo`-s for array of classes or interfaces as associative array key

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 6 03:42:58 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12303

           Summary: Different `TypeInfo`-s for array of classes or
                    interfaces as associative array key
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2014-03-06 15:42:56 MSK ---
Compiler passes different `TypeInfo`-s in case associative array key
is array of classes or interfaces. Consider the following example:
---
void main()
{
    Object[] a;
    typeid(Object[]).getHash(&a); // Calls TypeInfo_Array.getHash
    int[Object[]] aa = [a : 0];
    assert(a in aa); // Calls TypeInfo_AC.getHash
}
---

This code should work fine:
---
alias T = Object[];

extern(C) inout(void)* _aaInX(inout void*, in TypeInfo keyti, in void* pkey)
{
    assert(keyti is typeid(T)); // fails
    return null;
}
void main()
{
    T a;
    int[T] aa = [a : 0];
    assert(a !in aa);
}
---

And it works if `T` isn't an array of classes or interfaces.

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


More information about the Digitalmars-d-bugs mailing list