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

Stanislav Blinov <stanislav.bli...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stanislav.bli...@gmail.com

--- Comment #4 from Stanislav Blinov <stanislav.bli...@gmail.com> ---
Now that we have an .update() for AAs, this needs to be resolved. This test
should pass:

unittest {
    double[int] aa;
    aa[0]++;
    import std.math;
    assert(aa[0].isNaN);
}

The appropriate create/modify for non-zero-initialized types is:

unittest {
    double[int] aa;
    aa.update(0, { return 0.0; }, (ref double d) { d++; return d; });
    assert(aa[0] == 1.0);
}

Let's not let convenience defeat the type system, please.

--

Reply via email to