www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19422] New: Associative arrays break inference of safe,


          Issue ID: 19422
           Summary: Associative arrays break inference of  safe, nothrow,
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: stanislav.blinov gmail.com

struct S {
    int x;

    this(this) {
        /* do  system stuff... */
        import std.stdio;
    bool opEquals(S rhs) { return x == rhs.x; }
    size_t toHash() { return hashOf(x); }

void testS()  safe nothrow pure {
    S a;
    auto b = a;
    auto h = a.toHash();

void testAA()  safe nothrow pure {
    int[S] aa;
    S key;
    aa[key] = 0;

testS() will not compile since neither postblit, nor opEquals or toHash satisfy
the attributes.

But testAA() compiles, even though the AA implementation calls all the same

Nov 22 2018