You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say you tried to make a templated function, but one of the parameters' types isn't semantically correct. If you try to instantiate that function then you will only get an error at the point of instantiation telling you that you didn't 'match the template declaration', when you should really be getting an error from the malformed template. Here's an example:
autotemplateFn(alias a)(T b)
if(true){}
alias broken = templateFn!("hello!");
Outputs:
Error: template instance `templateFn!"hello!"` does not match
template declaration `templateFn(alias a)(T b)`'
Note that if the constraint if(true) is removed, then the correct error messages are displayed. In this case:
You can replace T in this example with any semantically incorrect type (i.e. where is(T) == false) and you get the result. It seems like when the parameter type is _error_ it gets silently allowed, and then it causes an error in the template constraint.
The text was updated successfully, but these errors were encountered:
ichordev
changed the title
Bad error message when broken template function with constraint is instantiated
Bad error message when template function with bad parameter type & constraint is instantiated
Jan 13, 2025
Let's say you tried to make a templated function, but one of the parameters' types isn't semantically correct. If you try to instantiate that function then you will only get an error at the point of instantiation telling you that you didn't 'match the template declaration', when you should really be getting an error from the malformed template. Here's an example:
Outputs:
Note that if the constraint
if(true)
is removed, then the correct error messages are displayed. In this case:You can replace
T
in this example with any semantically incorrect type (i.e. whereis(T) == false
) and you get the result. It seems like when the parameter type is_error_
it gets silently allowed, and then it causes an error in the template constraint.The text was updated successfully, but these errors were encountered: