[Issue 19422] New: Associative arrays break inference of @safe, nothrow, pure
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 22 20:51:55 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19422
Issue ID: 19422
Summary: Associative arrays break inference of @safe, nothrow,
pure
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: stanislav.blinov at gmail.com
struct S {
int x;
this(this) {
/* do @system stuff... */
import std.stdio;
writeln("copy");
}
const:
bool opEquals(S rhs) { return x == rhs.x; }
size_t toHash() { return hashOf(x); }
}
void testS() @safe nothrow pure {
S a;
auto b = a;
a.opEquals(b);
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
functions.
--
More information about the Digitalmars-d-bugs
mailing list