[Issue 18199] New: Error with lambda in struct initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 6 01:41:42 UTC 2018


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

--


More information about the Digitalmars-d-bugs mailing list