www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22152] New: Block statement at beginning of statement not


          Issue ID: 22152
           Summary: Block statement at beginning of statement not
                    recognized as function literal
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Ajieskola gmail.com

void main()
{ import std;
  {writeln("hello world");}();

Compilation attempt result:
app.d(3): Error: expression expected, not `)`
app.d(3): Error: found `;` when expecting `)`
app.d(4): Error: found `}` when expecting `;` following statement
app.d(5): Error: found `End of File` when expecting `}` following compound

The compiler should recognize the block statement as a function literal that is
immediately called.

Note that it will compile with this change:

void main()
{ import std;
  return {writeln("hello world");}();

Jul 27 2021