[Clang] Lambda in a `decltype()` in template parameters causing incorrect type mismatches
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The following code (minimal repro. example)
```cpp
template
struct X {};
template
using DistinctCollector = X;
DistinctCollector getCellSpreadItems()
{
DistinctCollector set;
return set;
}
int main() { getCellSpreadItems(); }
```
https://godbolt.org/z/obMWeKjKr
fails with
`error: no viable conversion from returned value of type 'DistinctCollector<...>' to function return type 'DistinctCollector<...>'`
The same error is not observed on GCC or MSVC (in conformance mode, iow `/permissive-`) compilers.
If you use
```cpp
auto getCellSpreadItems()
{
DistinctCollector set;
return set;
}
```
https://godbolt.org/z/4fnocEr13
it works.
Per @Sirraide on Discord:
> Looking at the AST, it seems like we’re instantiating that template twice; so it seems what it’s complaining about is that the two instances of `DistinctCollector` are ... not the same type, which er, is not quite right
> There are some things we try to diagnose even if the function is still dependent, but usually you need to instantiate it yes, and this also looks like a problem specifically w/ instantiation
Contributor guide
Assessment
This issue has not been assessed yet.