[Issue 11866] New: `@safe` and `nothrow` attributes aren't inferred for nested functions in templated functions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jan 5 00:35:11 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=11866

           Summary: `@safe` and `nothrow` attributes aren't inferred for
                    nested functions in templated functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: verylonglogin.reg at gmail.com


--- Comment #0 from Denis Shelomovskij <verylonglogin.reg at gmail.com> 2014-01-05 12:35:09 MSK ---
This code should compile:
---
void g(T)()
{
    void f(){ }
    f();
}

void main() @safe nothrow // line 7
{
    g!int(); // line 9
}
---
main.d(9): Error: safe function 'D main' cannot call system function
'main.g!int.g'
main.d(9): Error: 'main.g!int.g' is not nothrow
main.d(7): Error: function 'D main' is nothrow yet may throw
---

E.g. `std.algorithm.countUntil` isn't `nothrow` because of this as it uses
nested `pred2`.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list