www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12739] New: Foreach delegate to opApply does not have infered

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

          Issue ID: 12739
           Summary: Foreach delegate to opApply does not have infered
                    nothrow
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: safety0ff.bugz gmail.com

This doesn't work:
struct S
{
nothrow:
    int opApply(int delegate(ref int) nothrow dg)
    {
        return 0;
    }
}

void main() nothrow
{
    S s;
    foreach (e; s)
    {
    }
}

But this does:

struct S
{
nothrow:
    int opApply(int delegate(ref int) nothrow dg)
    {
        return 0;
    }
}

void main() nothrow
{
    S s;
    s.opApply(
        (ref int x) {
            return 0;
        }
    );
}

--
May 12 2014