[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 31 10:16:48 PST 2025
================
@@ -4870,14 +4870,16 @@ def note_ovl_candidate_inconsistent_deduction_types : Note<
"candidate template ignored: deduced values %diff{"
"of conflicting types for parameter %0 (%1 of type $ vs. %3 of type $)|"
"%1 and %3 of conflicting types for parameter %0}2,4">;
-def note_ovl_candidate_explicit_arg_mismatch_named : Note<
+def note_ovl_candidate_explicit_arg_mismatch : Note<
"candidate template ignored: invalid explicitly-specified argument "
- "for template parameter %0">;
+ "for %ordinal0 template parameter">;
+def note_ovl_candidate_explicit_arg_mismatch_detail : Note<
+ "%select{"
+ "|: expected a type, but got value '%1'"
+ "|: expected constant of type %3 but got type %1"
----------------
cor3ntin wrote:
This is still too much information, which is why it is a bit awkward.
When you pass a type to a value or the other way around (and don't forget the template parameter case),
it does not matter what that type, or that value is.
Which is why I proposed something like thar
`non-type|type|template argument 'foo' is not compatible with non-type|type|template template parameter 'bar'`
In particular it avoids the `expected constant of type int but got type int` - which is going be confusing for a lot of people (note that `expected constant of type int but got type char*` might arguably be even more misleading a one might think there is a conversion error when it fact the salient issue is that the argument and parameter are of different kinds altogether
https://github.com/llvm/llvm-project/pull/122754
More information about the cfe-commits
mailing list