Bug 16540 – Attributes do not propagate correctly in lazy params
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-09-25T20:35:00Z
Last change time
2017-08-07T13:16:11Z
Assigned to
nobody
Creator
eyal
Comments
Comment #0 by eyal — 2016-09-25T20:35:06Z
// 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.
Comment #1 by bugzilla — 2017-05-13T13:25:45Z
This is working successfully in the current DMD version.