https://issues.dlang.org/show_bug.cgi?id=21681
Issue ID: 21681
Summary: Can't deduce recursive template function attributes
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Example:
void foo(S)(ref S s, int a)
{
if (--a)
bar(s, a);
s.m();
}
void bar(S)(ref S s, int a)
{
if (--a)
foo(s, a);
s.m();
}
struct S
{
int s;
void m() @safe pure nothrow @nogc
{
s++;
}
}
void main() @safe pure nothrow @nogc
{
S s;
bar(s, 10);
}
================
> rdmd playground.d
onlineapp.d(27): Error: pure function D main cannot call impure function
onlineapp.bar!(S).bar
onlineapp.d(27): Error: @safe function D main cannot call @system function
onlineapp.bar!(S).bar
onlineapp.d(8): onlineapp.bar!(S).bar is declared here
onlineapp.d(27): Error: @nogc function D main cannot call non-@nogc function
onlineapp.bar!(S).bar
onlineapp.d(27): Error: function onlineapp.bar!(S).bar is not nothrow
onlineapp.d(24): Error: nothrow function D main may throw
--