[Issue 11907] No undeclared identifier error in lambda alias argument
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 1 21:52:48 UTC 2023
https://issues.dlang.org/show_bug.cgi?id=11907
Nick Treleaven <nick at geany.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nick at geany.org
--- Comment #3 from Nick Treleaven <nick at geany.org> ---
Note: issue also applies when constraint is `__traits(compiles, a())`.
> Ideally, the error would be: foo.d(5): Error: undeclared identifier 'blarg'
The problem is that the lambda is a template, and templates aren't semantically
analyzed until instantiated. If the constraint wasn't there then the body would
likely instantiate the lambda somewhere and produce the desired error. In this
case the lambda is trivial and some kind of analysis without types could detect
the error, but not in the general case where the lambda doesn't compile for
other reasons, e.g. `x => x.typo`. As a workaround, the constraint expression
could be moved to a `static if` test in the body.
--
More information about the Digitalmars-d-bugs
mailing list