Thread overview
[Issue 16672] Deprecate "block only" delegate syntax
Nov 10, 2016
Nick Treleaven
Nov 11, 2022
RazvanN
Nov 13, 2022
Nick Treleaven
Nov 14, 2022
RazvanN
Nov 14, 2022
Nick Treleaven
Dec 17, 2022
Iain Buclaw
November 10, 2016
https://issues.dlang.org/show_bug.cgi?id=16672

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #1 from Nick Treleaven <nick@geany.org> ---
Link to most recent question on the forum: http://forum.dlang.org/post/pcbqcrujjewmdptuggsy@forum.dlang.org

Andrei uncovered this gem:

int j;
for({j=2; int d = 3; } j+d<7; {j++; d++;}) {
}

http://forum.dlang.org/thread/nud21i$o29$1@digitalmars.com

As he explains, the Initialize part of `for` grammar specially allows BlockStatement, but the Increment part is just an expression. So {j++; d++;} is an expression, *not* a BlockStatement, which parses as a nullary delegate, which is never called! Hence infinite loop.

Andrei also mentions an alternative fix:

> Another possibility is to disallow an ExpressionStatement that consists solely of a lambda. There is precedent for that, e.g. the statement "1 + 1;" is disallowed. -- Andrei

--
November 11, 2022
https://issues.dlang.org/show_bug.cgi?id=16672

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> ---
*** Issue 16632 has been marked as a duplicate of this issue. ***

--
November 11, 2022
https://issues.dlang.org/show_bug.cgi?id=16672

--- Comment #3 from Steven Schveighoffer <schveiguy@gmail.com> ---
Technically, the single expression lambda syntax problem is fixed, as it's now deprecated.

--
November 13, 2022
https://issues.dlang.org/show_bug.cgi?id=16672

--- Comment #4 from Nick Treleaven <nick@geany.org> ---
(In reply to Nick Treleaven from comment #1)
> int j;
> for({j=2; int d = 3; } j+d<7; {j++; d++;}) {

This will be caught by issue #23480.

--
November 14, 2022
https://issues.dlang.org/show_bug.cgi?id=16672

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #5 from RazvanN <razvan.nitu1305@gmail.com> ---


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

--
November 14, 2022
https://issues.dlang.org/show_bug.cgi?id=16672

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |---

--- Comment #6 from Nick Treleaven <nick@geany.org> ---
This issue is not related to the `for` statement. Rather the `for` issue was related to this.

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--