Bug 22152 – Block statement at beginning of statement not recognized as function literal
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-07-27T23:01:30Z
Last change time
2021-07-28T00:51:55Z
Assigned to
No Owner
Creator
Ate Eskola
Comments
Comment #0 by Ajieskola — 2021-07-27T23:01:30Z
```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");}();
}
```
Comment #1 by b2.temp — 2021-07-28T00:51:55Z
*** This issue has been marked as a duplicate of issue 21619 ***