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: [email protected]
        ReportedBy: [email protected]


--- Comment #0 from Denis Shelomovskij <[email protected]> 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: -------

Reply via email to