[Issue 21681] New: Can't deduce recursive template function attributes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 6 05:36:12 UTC 2021


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: nobody at puremagic.com
          Reporter: ilyayaroshenko at gmail.com

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- at 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

--


More information about the Digitalmars-d-bugs mailing list