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
With DMD 2.065, the following code fails to compile:
import std.stdio;
mixin template Foo(T){
T foo(T a){ return a; }
}
mixin Foo!int g;
mixin Foo!string g;
void main(){
writeln(foo(2));
writeln(foo("a"));
writeln(g.foo(2));
writeln(g.foo("a"));
}
Error: mixin tt.Foo!(string) conflicts with mixin tt.Foo!(int) at tt.d(6)
Similarly if two named mixins occur in different files:
module b;
mixin template Foo(T){
T foo(T a){ return a; }
}
mixin Foo!string g;
// ---
module c;
mixin template Foo(T){
T foo(T a){ return a; }
}
mixin Foo!int g;
// ---
import std.stdio;
import b,c;
void main(){
writeln(foo(2));
writeln(foo("a"));
writeln(g.foo(2));
writeln(g.foo("a"));
}
Error: b.Foo!(string) at b.d(5) conflicts with c.Foo!(int) at c.d(5)
Error: function b.Foo!(string).foo (string a) is not callable using argument types (int)
Error: cannot implicitly convert expression (2) of type int to string
Error: b.Foo!(string) at b.d(5) conflicts with c.Foo!(int) at c.d(5)
Both examples should compile.
The text was updated successfully, but these errors were encountered:
Generally, symbols mixed in at module level conflict. E.g.:
mixin template Preparer()
{
bool isPrepared;
}
when mixed into multiple modules causes conflicts when accessing `isPrepared`. In particular `fully.qualified.module.name.isPrepared` does not help the compiler distinguish the symbols either.
timon.gehr reported this on 2014-04-26T21:44:34Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=12659
CC List
Description
With DMD 2.065, the following code fails to compile: import std.stdio; mixin template Foo(T){ T foo(T a){ return a; } } mixin Foo!int g; mixin Foo!string g; void main(){ writeln(foo(2)); writeln(foo("a")); writeln(g.foo(2)); writeln(g.foo("a")); } Error: mixin tt.Foo!(string) conflicts with mixin tt.Foo!(int) at tt.d(6) Similarly if two named mixins occur in different files: module b; mixin template Foo(T){ T foo(T a){ return a; } } mixin Foo!string g; // --- module c; mixin template Foo(T){ T foo(T a){ return a; } } mixin Foo!int g; // --- import std.stdio; import b,c; void main(){ writeln(foo(2)); writeln(foo("a")); writeln(g.foo(2)); writeln(g.foo("a")); } Error: b.Foo!(string) at b.d(5) conflicts with c.Foo!(int) at c.d(5) Error: function b.Foo!(string).foo (string a) is not callable using argument types (int) Error: cannot implicitly convert expression (2) of type int to string Error: b.Foo!(string) at b.d(5) conflicts with c.Foo!(int) at c.d(5) Both examples should compile.The text was updated successfully, but these errors were encountered: