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 }
Comment #1 by k.hara.pg — 2011-11-25T22:51:52Z
Comment #2 by github-bugzilla — 2012-11-19T14:32:36Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/cd2b0c924917ab75f3efeaf7eeaff3fa414844ed fix Issue 7017 - Pure inference makes inconsistent result https://github.com/D-Programming-Language/dmd/commit/e3daa5ed3e869d793e5c3a74be89842c248346f0 Merge pull request #536 from 9rnsr/fix7017 Issue 7017 - Pure inference makes inconsistent result