www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14600] New: Lambda with body allowed as template alias argument

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: nobody puremagic.com
          Reporter: johnch_atms hotmail.com

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.

--
May 18 2015