Issue 3825 and 3789

bearophile bearophileHUGS at lycos.com
Sun Mar 3 18:47:48 PST 2013


A bit of celebration is in order because step by step D is 
becoming usable :-)
DMD 2.063 will have a significant improvement, this bug seems now 
fixed:

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


This program:


import std.stdio;
void main() {
     string[] words = ["how", "are", "you", "are"];

     int[string] aa1;
     foreach (w; words)
         aa1[w] = (w in aa1) ? (aa1[w] + 1) : 2;
     writeln(aa1);

     int[string] aa2;
     foreach (w; words)
         if (w in aa2)
             aa2[w]++;
         else
             aa2[w] = 2;
     writeln(aa2);


Used to write:
["how":1, "you":1, "are":2]
["how":2, "you":2, "are":3]

Now it writes:
["how":2, "are":3, "you":2]
["how":2, "are":3, "you":2]

This bug fix removes a big trap of D AAs.

---------------

Currently this is near the top of my wish list of bugs:
"Structs members that require non-bitwise comparison not 
correctly compared":

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

Fixing 3789 will remove another significant class of bugs from D 
programs.

Bye,
bearophile


More information about the Digitalmars-d mailing list