[Issue 16001] Lambda syntax: forbid use with FunctionLiteralBody: (x) => {assert(x);}
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 18 13:33:16 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=16001
Dlang Bot <dlang-bot at dlang.rocks> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |pull
--- Comment #2 from Dlang Bot <dlang-bot at dlang.rocks> ---
@adamdruppe updated dlang/dmd pull request #12528 "deprecate the common mistake
people make coming from Javascript and C#" fixing this issue:
- fix issue 16001
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