[Issue 13840] New: nothrow attribute affects inside of try-catch block when using foreach with opApply

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Dec 9 00:08:01 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13840

          Issue ID: 13840
           Summary: nothrow attribute affects inside of try-catch block
                    when using foreach with opApply
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: sinkuupump at gmail.com

This is a regression introduced by
https://github.com/D-Programming-Language/dmd/pull/3956

```
struct Foo
{
    int opApply(int delegate(int))
    {
        return 0;
    }
}

void func()
{
}

void main() nothrow
{
    try
    {
        // *** Error: delegate 'bug.main.__foreachbody1' is nothrow yet may
throw
        foreach (i; Foo())
        {
            func(); // *** Error: 'bug.func' is not nothrow
        }
    }
    catch {}


    // same for scope(failure)
    scope(failure) assert(0);

    // *** Error: delegate 'bug.main.__foreachbody2' is nothrow yet may throw
    foreach (i; Foo())
    {
        func(); // *** Error: 'bug.func' is not nothrow
    }
}
```

--


More information about the Digitalmars-d-bugs mailing list