[Issue 22152] New: Block statement at beginning of statement not recognized as function literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jul 27 23:01:30 UTC 2021
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 at puremagic.com
Reporter: Ajieskola at 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");}();
}
```
--
More information about the Digitalmars-d-bugs
mailing list