digitalmars.D.bugs - [Issue 22152] New: Block statement at beginning of statement not
- d-bugmail puremagic.com (38/38) Jul 27 2021 https://issues.dlang.org/show_bug.cgi?id=22152
https://issues.dlang.org/show_bug.cgi?id=22152 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 ```d 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 statement ``` The compiler should recognize the block statement as a function literal that is immediately called. Note that it will compile with this change: ```d void main() { import std; return {writeln("hello world");}(); } ``` --
Jul 27 2021