Bug 6359 – Pure/@safe-inference should not be affected by __traits(compiles)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-07-20T14:35:00Z
Last change time
2014-06-06T16:49:59Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
kennytm
Comments
Comment #0 by kennytm — 2011-07-20T14:35:16Z
Test case:
------------------------------
@system void f6359() {}
pure void bug6359()() {
static if (__traits(compiles, f6359())) { // <-- this won't compile
static assert(0);
}
}
void g6359() pure nothrow @safe {
bug6359();
}
------------------------------
x.d(9): Error: safe function 'g6359' cannot call system function 'bug6359'
------------------------------
The stuff inside `__traits(compiles, )` won't affect the purity/safety of the program. Therefore, in the inference, the failed semantic to the @system function `f6359` should not make `bug6359()` not able to be @safe.
The same happens if the annotation of `bug6359` is changed to @safe, which now it is no longer inferable as pure.
nothrow is not affected.