www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18199] New: Error with lambda in struct initializer

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

          Issue ID: 18199
           Summary: Error with lambda in struct initializer
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: elronnd elronnd.net

With the following code:


struct Bla {
        int delegate(int, int) fun;
}
void main() {
        Bla bla1 = Bla((int a, int b) { return a + b; }); // works
        Bla bla2 = {(int a, int b) { return a + b; }}; // errors                
}


There is this cryptic error:


t.d(6): Error: found } when expecting ; following statement
t.d(6): Deprecation: use { } for an empty statement, not ;
t.d(8): Error: semicolon expected, not EOF
t.d(8): Error: found EOF when expecting } following compound statement


If nothing else, the error message should be improved, but shouldn't the second
line be valid?

--
Jan 05