[Issue 16001] Lambda syntax: forbid use with FunctionLiteralBody: (x) => {assert(x);}

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed May 26 23:47:28 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=16001

Dlang Bot <dlang-bot at dlang.rocks> changed:

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

--- Comment #3 from Dlang Bot <dlang-bot at dlang.rocks> ---
dlang/dmd pull request #12528 "Fix 16001 - forbid lambda syntax followed by
FunctionLiteralBody" was merged into master:

- 7e9c5705e15fc980bd92f3752377ba75f2e73d12 by Adam D. Ruppe:
  fix issue 16001 - forbid lambda syntax followed by FunctionLiteralBody

  A common mistake D users make - sometimes even experienced D users - is
  to use `() => { multi; line; lambda; }`. This syntax is common in
  several other languages, including D's syntax relatives of Javascript
  and C#, but in D, it is completely different (yet frequently still
  compiles!)  and leaves users puzzled why their code seemingly does
  nothing.

  This deprecation is aimed very specifically at that syntax rather than
  the semantic construct to warn them that they're doing it wrong and it
  offers easy suggestions to clarify their intent with existing D syntax,
  similarly to how `if(a = x)` and switch fallthrough was deemed more
  error-prone than it was worth given the easy and clear alternatives.

https://github.com/dlang/dmd/pull/12528

--


More information about the Digitalmars-d-bugs mailing list