Bug 21619 – Parameter-less function literal in expression statement fails to parse

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-02-09T03:45:46Z
Last change time
2024-12-13T19:14:30Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Paul Backus
Blocks
10233
Moved to GitHub: dmd#18021 →

Comments

Comment #0 by snarwin+bugzilla — 2021-02-09T03:45:46Z
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.
Comment #1 by b2.temp — 2021-07-28T00:51:55Z
*** Issue 22152 has been marked as a duplicate of this issue. ***
Comment #2 by nick — 2023-02-19T21:45:48Z
This requires arbitrary lookahead to parse. We could add a better error message though. (Workaround `() { ... }();`). Maybe we can fix the grammar by moving BlockStatment before anything that can be a NonEmptyStatement.
Comment #3 by nick — 2023-03-23T17:43:36Z
*** Issue 14378 has been marked as a duplicate of this issue. ***
Comment #4 by dlang-bot — 2023-08-26T11:46:33Z
@ntrel created dlang/dlang.org pull request #3690 "[spec] Describe parameter-less function literal" mentioning this issue: - [spec] Describe parameter-less function literal Part of issue 21619. Also split short syntax section in two. https://github.com/dlang/dlang.org/pull/3690
Comment #5 by dlang-bot — 2023-08-28T06:19:34Z
dlang/dlang.org pull request #3690 "[spec] Describe parameter-less function literal" was merged into master: - eafc6b71d079a84902d8976a2a58826b1317ab00 by Nick Treleaven: [spec] Describe parameter-less function literal Part of issue 21619. Also split short syntax section in two. https://github.com/dlang/dlang.org/pull/3690
Comment #6 by robert.schadek — 2024-12-13T19:14:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18021 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB