[Issue 16540] New: Attributes do not propagate correctly in lazy params

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Sep 25 13:35:06 PDT 2016


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 at puremagic.com
          Reporter: eyal at 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.

--


More information about the Digitalmars-d-bugs mailing list