www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21619] New: Parameter-less function literal in expression

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

          Issue ID: 21619
           Summary: Parameter-less function literal in expression
                    statement fails to parse
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

Example program:

---
void main()
{
    { assert(true); }();
}
---

Output from DMD 2.095.0:

---
bug.d(3): Error: expression expected, not )
bug.d(3): Error: found ; when expecting )
bug.d(4): Error: found } when expecting ; following statement
bug.d(5): Error: found End of File when expecting } following compound
statement
---

According to the language spec, line 3 should be parsed as an
ExpressionStatement.

--
Feb 08 2021