Bug 12303 – Different `TypeInfo`-s for array of classes or interfaces as associative array key

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-06T03:42:56Z
Last change time
2024-12-13T18:17:48Z
Keywords
wrong-code
Assigned to
No Owner
Creator
Denis Shelomovskii
Moved to GitHub: dmd#18788 →

Comments

Comment #0 by verylonglogin.reg — 2014-03-06T03:42:56Z
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.
Comment #1 by verylonglogin.reg — 2014-03-06T03:47:54Z
Filed Issue 12304 for the fact `TypeInfo_AC` is used for array of interfaces.
Comment #2 by robert.schadek — 2024-12-13T18:17:48Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18788 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB