Thread overview
[Issue 14378] Parse block statement followed by ';' as a function literal
[Issue 14378] ExpressionStatement incorrectly parsed as BlockStatement
Mar 31, 2015
Mathias LANG
Mar 31, 2015
Ketmar Dark
Mar 31, 2015
Ketmar Dark
Apr 11, 2015
yebblies
Dec 17, 2022
Iain Buclaw
Mar 23, 2023
Nick Treleaven
March 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14378

Mathias LANG <pro.mathias.lang@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pro.mathias.lang@gmail.com

--
March 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14378

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
i believe that delegates must have parameter declaration before body.

what we got here is block statement followed by empty statement (";"). so compiler can cry about the last if it wants, but not about delegate.

--
March 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14378

--- Comment #2 from briancschott@gmail.com ---
http://dlang.org/grammar.html#FunctionLiteralBody

Function literals do not require parameter lists.

It's perfectly valid to parse the example code as a function literal.

--
March 31, 2015
https://issues.dlang.org/show_bug.cgi?id=14378

--- Comment #3 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
ahem. so it's a bug in specs, i believe, 'cause it's very hard to distinguish block statements from function literals with the current definition, and it's not intuitive at all.

thank you, i somehow missed that thing in specs. making semicolon the only difference is puzzling for programmer.

would you mind to open a topic in NG for this? i believe that in this case specs must be fixed, not compiler.

--
April 11, 2015
https://issues.dlang.org/show_bug.cgi?id=14378

yebblies <yebblies@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies@gmail.com
            Summary|ExpressionStatement         |Parse block statement
                   |incorrectly parsed as       |followed by ';' as a
                   |BlockStatement              |function literal
           Severity|normal                      |enhancement

--- Comment #4 from yebblies <yebblies@gmail.com> ---
AFAIK this is intentional.  If this context is ambiguous, it will be parsed as a block statement.  You will probably want to make this a spec bug, but I'll leave that to you.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14378

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
March 23, 2023
https://issues.dlang.org/show_bug.cgi?id=14378

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |nick@geany.org
         Resolution|---                         |DUPLICATE

--- Comment #5 from Nick Treleaven <nick@geany.org> ---
Marking as duplicate as the other issue is clearer about action needed.

*** This issue has been marked as a duplicate of issue 21619 ***

--