https://issues.dlang.org/show_bug.cgi?id=14600
Issue ID: 14600
Summary: Lambda with body allowed as template alias argument
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: [email protected]
Reporter: [email protected]
When run, the following program compiles without error but produces no output.
void test(alias d)() {
d();
}
void main() {
import std.stdio : writeln;
test!(() => { writeln("testing"); });
}
Compare to the following code, which does not compile because the => syntax is
only supposed to work with simple expressions.
void test(void delegate() d) {
d();
}
void main() {
import std.stdio : writeln;
test(() => { writeln("testing"); });
}
Maybe the restriction on the => syntax not allowing bracketed expressions
should be lifted. I've spotted code on github that assumes this style does
actually work.
--