www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15290] New: length of associative array literal with

https://issues.dlang.org/show_bug.cgi?id=15290

          Issue ID: 15290
           Summary: length of  associative array literal with duplicate
                    keys is wrong
           Product: D
           Version: D2
          Hardware: x86_64
               URL: http://forum.dlang.org/thread/rlxkowykiacokdxkehra for
                    um.dlang.org
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: schuetzm gmx.net

void main()
{
    import std.stdio : writeln;
    ["key": 10, "key" : 20, "key" : 30].length.writeln;
    ["key" : 30].length.writeln;
}

This prints:
3
1

In general, duplicate keys in literals should probably be disallowed anyway:
https://issues.dlang.org/show_bug.cgi?id=11637

--
Nov 05 2015