D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6359 - Pure/@safe-inference should not be affected by __traits(compiles)
Summary: Pure/@safe-inference should not be affected by __traits(compiles)
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords: pull, rejects-valid
Depends on:
Blocks:
 
Reported: 2011-07-20 14:35 UTC by kennytm
Modified: 2014-06-06 16:49 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description kennytm 2011-07-20 14:35:16 UTC
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.
Comment 2 github-bugzilla 2014-06-06 16:49:58 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/94c11fd9ed43d81d853e94c6af4c782b7c0d195a
fix Issue 6359 - Pure/@safe-inference should not be affected by __traits(compiles)

https://github.com/D-Programming-Language/dmd/commit/e051d119243a56b2bff11e8c47d3a634631d58ad
Merge pull request #3625 from 9rnsr/fix6359

Issue 6359 - Pure/@safe-inference should not be affected by __traits(compiles)