www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2684] New: Associative arrays have wrong opIndex signatures

reply d-bugmail puremagic.com writes:
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 digitalmars.com
        ReportedBy: andrei 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.


-- 
Feb 22 2009
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2684


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla digitalmars.com  2009-03-11 14:59 -------
Fixed dmd 2.026


-- 
Mar 11 2009