Open
Description
Consider this example: https://compiler-explorer.com/z/bGqdsa3qc
template<typename U> struct A {
U t;
};
template<typename V> A(V) -> A<V>;
namespace foo {
template<class Y> using Alias = A<Y>;
}
foo::Alias t = 0;
Produces:
error: no viable conversion from 'int' to 'foo::A<int>' (aka 'A<int>')
Note that the foo::
qualification is applied to Alias in the source code, which is in that namespace, but
on the AST (and consequently in the diagnostic) it gets applied to A
, where it cannot be found.
The problem here is many fold:
- We have an elaborated type including
foo::
over the deduced template specialization (DTST), which namesfoo::Alias
. - However, when printing a DTST which has already been deduced, we choose to print it as the deduced type instead, probably for diagnostics reasons (although this is wrong for -ast-print, and we don't control this with a policy).
- For alias CTAD, we don't build a guide which actually contains the alias template specialization
Alias<int>
, instead the guide containsA<int>
.
I see a couple of solutions:
- If we fix 3, then this would print as intended:
'foo::Alias<int>' (aka 'A<int>')
- We could stop doing 2, then this would print as
'foo::Alias' (aka 'A<int>')
.
The first type does not include much information, as 2) probably intended to avoid, but it is correctly qualified, and then the 'aka' gives the missing information.