www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21163] New: Scope lambda argument in struct initializer

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

          Issue ID: 21163
           Summary: Scope lambda argument in struct initializer causes
                    parsing error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

The following program fails to compile with dmd 2.093.0:

---
struct S
{
    void function(scope int) fp;
}

S s = {
    fp: (scope int x) {}
};
---

The compiler's output:

$ dmd -c bug.d 
bug.d(8): Error: found `}` when expecting `;` following statement
bug.d(8): Deprecation: use `{ }` for an empty statement, not `;`
bug.d(9): Error: found `End of File` when expecting `}` following compound
statement
bug.d(9): Error: semicolon expected, not `End of File`

--
Aug 15 2020