Test case: ---------------------- pure int h() { return 1; } int f(alias g)() { return g(); } pure int i() { return f!h(); } ---------------------- x.d(8): Error: pure function 'i' cannot call impure function 'f' ---------------------- The instantiation f!h should be detected as pure, but currently DMD on git master fails to do so. nothrow and @safe are correctly inferred.
Actually the problem is not due to the template alias parameter, but because 'CallExp::semantic' calls 'Expression::checkPurity' which calls 'FuncDeclaration::isPure' on the outer function, and stops its inference with 'setImpure'. Two more test cases: ------------------------ pure int h() { return 1; } int f()() { return h(); } pure int i() { return f(); } ------------------------- ------------------------- pure int h() { return 1; } pure int i() { return { return h(); }(); } -------------------------
DMD pull #222. https://github.com/D-Programming-Language/dmd/pull/222
https://github.com/D-Programming-Language/dmd/commit/b4107b88a3acac76f31bafcad664c48df760ee01