Thread overview
[Issue 11907] No undeclared identifier error in lambda alias argument
Jul 04, 2020
Basile-z
Dec 17, 2022
Iain Buclaw
Feb 01, 2023
Nick Treleaven
Feb 01, 2023
Nick Treleaven
Feb 01, 2023
Nick Treleaven
July 04, 2020
https://issues.dlang.org/show_bug.cgi?id=11907

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
the diagnostic is better nowdays:

---
/tmp/temp_7F0C787490B0.d(5,5): Error: template instance
`temp_7F0C787490B0.main.f!((x) => blarg)` does not match template declaration
`f(alias a)()`
  with `a = __lambda1`
  must satisfy the following constraint:
`       is(typeof(a()))`
---

good enough to close ?

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P3

--
February 01, 2023
https://issues.dlang.org/show_bug.cgi?id=11907

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |grimmaple95@gmail.com

--- Comment #2 from Nick Treleaven <nick@geany.org> ---
*** Issue 23663 has been marked as a duplicate of this issue. ***

--
February 01, 2023
https://issues.dlang.org/show_bug.cgi?id=11907

Nick Treleaven <nick@geany.org> changed:

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

--- Comment #3 from Nick Treleaven <nick@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.

--
February 01, 2023
https://issues.dlang.org/show_bug.cgi?id=11907

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=14217

--