[Issue 7017] New: Pure inference makes inconsistent result
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 25 22:24:44 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7017
Summary: Pure inference makes inconsistent result
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2011-11-25 22:23:44 PST ---
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
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list