Bug 19869 – `FunctionLiteral` allows incorrect forms

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-05-14T00:32:38Z
Last change time
2022-07-29T08:10:12Z
Assigned to
No Owner
Creator
Basile-z
Blocks
10233

Comments

Comment #0 by b2.temp — 2019-05-14T00:32:38Z
https://dlang.org/spec/expression.html#FunctionLiteralBody PrimaryExpression: ... FunctionLiteral FunctionLiteral: ... FunctionLiteralBody FunctionLiteralBody: ... FunctionContractsopt BodyStatement Says that auto b = do {return true;}(); Is valid, which is not. Maybe It says that auto a = in{assert(true);} do {return true;}(); would be correct but it's not either. Note that in the rules BodyStatement is not a valid one. Its target anchor does not exist.
Comment #1 by b2.temp — 2019-05-14T00:59:45Z
BodyStatement is probably for https://dlang.org/spec/function.html#SpecifiedFunctionBody There are two options: 1. The easy way, remove the rule 2. Fix the compiler to allow `FunctionContractsopt SpecifiedFunctionBody` as subrule of FunctionLiteralBody
Comment #2 by dlang-bot — 2022-07-23T13:47:54Z
@ntrel created dlang/dlang.org pull request #3350 "[spec] Fix Issue 19869 - `FunctionLiteral` allows incorrect forms" mentioning this issue: - [spec] Fix Issue 19869 - `FunctionLiteral` allows incorrect forms SpecifiedFunctionBody allows `do` and contracts. https://dlang.org/spec/function.html#SpecifiedFunctionBody https://github.com/dlang/dlang.org/pull/3350
Comment #3 by nick — 2022-07-23T13:53:31Z
*** Issue 15620 has been marked as a duplicate of this issue. ***
Comment #4 by dlang-bot — 2022-07-27T09:40:49Z
dlang/dlang.org pull request #3350 "Fix Issue 19869 - `FunctionLiteral` allows incorrect forms" was merged into master: - e37ea0ca77ef0d8ecb65637a315a3921b258b7aa by Nick Treleaven: [spec] Fix Issue 19869 - `FunctionLiteral` allows incorrect forms SpecifiedFunctionBody allows `do` and contracts. https://dlang.org/spec/function.html#SpecifiedFunctionBody https://github.com/dlang/dlang.org/pull/3350