<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112410>112410</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL] Template parameter elision creates confusing Diagnostics for mismatched vector (matrix) templates
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics,
HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pow2clk
</td>
</tr>
</table>
<pre>
Because HLSL vector types (and soon matrices) are defined as templates, some of the diagnostics will treat them as user-defined templates that don't match in all the particulars instead of printing them as types in their diagnostic messages.
These take the form of eliding the template elements that match, which makes it unclear what HLSL types they refer to or even that they refer to HLSL types. Two examples:
```
cannot initialize a variable of type 'vector<[...], 4>' with an lvalue of type 'vector<[...], 3>'
assigning to 'matrix<float, [2 * ...]>' from incompatible type 'matrix<int, [2 * ...]>
```
This can be seen in [this test](https://github.com/llvm/llvm-project/blob/66f968cf3725a9d3554765c900f9c2de75190a87/clang/test/SemaHLSL/standard_conversion_sequences.hlsl#L88) and will manifest in several of the new matrix tests.
The elision could be removed, but that would change behavior elsewhere. Perhaps a preferrable solution would be to direct these diagnostic prints to places where the types get printed instead of the more generic template outputs. These don't involve TypePrinter at all, rather the output comes from the TemplateDiff class in ASTDiagnostics.c https://github.com/llvm/llvm-project/blob/fe7f5f9126cea9ceba703d5bd07b766181f2bd72/clang/lib/AST/ASTDiagnostic.cpp#L2029
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU1v4zYQ_TX0ZbCCRFmSdfAhiWv0kMMC8X0xIkcWG4pUSUpO-usLUrbjoi3QLhAoMMl58_XeDHqvzoZoz6pnVh02OIfBuv1kL1zo901n5ef-mQTOnuDX17dXWEgE6yB8TuSB8R0aCd5aAyMGpwR5xltARyCpV4YkoIdA46QxxLsX8HYksD2EgUAqPBvrgxIeLkprCI4wxKsx2s2e3Lcbzh0EwoABpDWMNy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