www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16540] New: Attributes do not propagate correctly in lazy

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

          Issue ID: 16540
           Summary: Attributes do not propagate correctly in lazy params
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: eyal weka.io

// Compiles just fine:

void foo(scope int* delegate() f)  nogc {
}

void bar()  nogc {
    foo({ return new int(5); });
}

// Fails:

void foo1(scope lazy int* f)  nogc {
}

void bar1()  nogc {
    foo(new int(5)); // It does not understand that the new here is wrapped in
an invisible delegate
}

---

This is a real problem in the context of an assertion template that wants to
declare itself pure,  nogc, etc -- because it is. Only when the assert fails,
it is GC'd, non-pure, etc, but in those case we abort anyway so all of those
properties are not visible to the caller.

--
Sep 25 2016