Weird template error message
NaN
divide at by.zero
Fri May 15 21:40:20 UTC 2020
Stripped down example...
module test;
import std.traits;
auto offsetBy(T,F)(T path, F x, F y)
{
alias PathFloat = TemplateArgsOf!T[0];
struct Offseter(Q)
{
Q path;
PathFloat x;
PathFloat y;
}
return Offseter(path, cast(PathFloat) x, cast(PathFloat) y);
}
void Foo()
{
struct Path(T) { T a; }
Path!float p;
offsetBy(p, 1, 1);
}
---->
<source>(18): Error: struct `test.offsetBy!(Path!float,
int).offsetBy.Offseter` cannot deduce function from argument
types `!()(Path!float, float, float)`, candidates are:
<source>(11): `test.offsetBy!(Path!float,
int).offsetBy.Offseter(Q)`
<source>(25): Error: template instance
`test.offsetBy!(Path!float, int)` error instantiating
Compiler returned: 1
(ldc 1.17)
If you look at the template parameters in the error message
you'll see "offsetBy!(Path!float, int)"
which is clearly wrong... is it a compiler bug, or just a crappy
error message?
More information about the Digitalmars-d
mailing list