Bug 7017 – Pure inference makes inconsistent result
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-11-25T22:23:00Z
Last change time
2012-11-19T17:51:59Z
Keywords
accepts-invalid, patch
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2011-11-25T22:23:44Z
Pure/nothrow/@safe inference with template function is shallow.
It does not affect to nested non-template struct member functions.
But in following code, map template function inferred as pure in some cases.
This is pure inference bug.
template map(fun...) if (fun.length >= 1)
{
auto map()
{
struct Result {
this(int dummy){} // impure member function
}
return Result(0); // impure call
}
}
int foo(immutable int x) pure nothrow { return 1; }
void main() pure
{
int bar(immutable int x) pure nothrow { return 1; }
static assert(!__traits(compiles, map!((){})())); // should pass, but fails
static assert(!__traits(compiles, map!q{ 1 }())); // pass, OK
static assert(!__traits(compiles, map!foo())); // pass, OK
static assert(!__traits(compiles, map!bar())); // should pass, but fails
}