[Issue 2684] New: Associative arrays have wrong opIndex signatures

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Feb 22 07:47:25 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2684

           Summary: Associative arrays have wrong opIndex signatures
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: andrei at metalanguage.com


void main()
{
    int[string] x;
    char[] y;
    if (y in x){}
    int z = x[y];
}

The last two lines do not compile. However it makes of course sense to look up
for a char[] or const(char)[] in a hash keyed by immutable(char)[]. Only the
operator that inserts stuff into the hash should force the type
immutable(char)[].

Bottom line: if the type of the key is K, any type K1 that allows comparison
for equality and less-than with K should be accepted for lookup.


-- 



More information about the Digitalmars-d-bugs mailing list