On Tuesday, 14 July 2015 at 17:24:41 UTC, anonymous wrote:
This fails with "Error: None of the overloads of 'cos' are
callable using argument types (int[])".
The problem is that template mixins cannot add to existing
overload sets. The spec says: "If the name of a declaration in
a mixin is the same as a declaration in the surrounding scope,
the surrounding declaration overrides the mixin one" [1]. That
means, the `cos` from `alias cos = std.math.cos;` completely
overrides the one from `mixin t!();`. I guess this is a measure
against function hijacking again.
I'm not sure if it's supposed to work like it does when the
alias is removed, two implicitly imported/generated symbols
forming an overload set. But I can't immediately see a problem
with it either.
[1] http://dlang.org/template-mixin.html - see "Mixin Scope"
That's a great explanation. It doesn't seem like a bug or
anything. It's just alias and template mixins are two areas of D
that I'm less familiar with. Combining them together pushes my
understanding a bit.