<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118187>118187</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Cannot call lambda defined in immediate lambda
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
LHLaurini
</td>
</tr>
</table>
<pre>
The following code compiles on both GCC and MSVC, but is refused by Clang ([Godbolt link](https://godbolt.org/z/M7KdM36YE)):
```c++
void func_1(auto)
{
[](auto) consteval
{
[](auto)
{
}(123);
};
}
auto func_2()
{
func_1(123);
}
```
The error message:
```
<source>:6:9: error: no matching function for call to object of type '(lambda at <source>:6:9)'
6 | [](auto)
| ^~~~~~~~
7 | {
| ~
8 | }(123);
| ~
<source>:5:5: note: while substituting into a lambda expression here
5 | {
| ^
<source>:14:5: note: in instantiation of function template specialization 'func_1<int>' requested here
14 | func_1(123);
| ^
<source>:6:9: note: candidate template ignored: couldn't infer template argument 'auto:1'
6 | [](auto)
| ^
1 error generated.
```
>From my experimentation:
- `func_1` must be a function template;
- The outer lambda must be immediate;
- The outer lambda must be a lambda template;
- The inner lambda must be a lambda template.
Note: the code from which I wrote this test-case is almost the same where I originally found #117676, so there could be some relation (or not).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1v4zYQ_TX0ZRCDomJJPujgOPF20U0vLQr0VFDkSGJLkS5Jxc0e-tuLkeTEcQI0qCDDhObrzXtDUsZoOodYs80d29yv5Jh6H-pvP3yTYzDOrBqvn-tfeoTWW-tPxnWgvEZQfjgaixG8g8anHr7s9yCdhseff90zsYdmTGAiBGzHiBqaZ9hb6TpgomKbuy9eN94msMb9yTb3TFR9SsfI8h0TByYO3Wxf-9AxcfjOxOGx_FE_5sVvD0xs6c13jO9YwedXMXFHL989eaOhHZ36PWOikmPy5M13rCQrzH2-WkB5FxM-SUtWAFj8lufa_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