Bug 12659 – Module level mixin templates conflict

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-04-26T21:44:34Z
Last change time
2024-12-13T18:20:10Z
Assigned to
No Owner
Creator
timon.gehr
Moved to GitHub: dmd#18821 →

Comments

Comment #0 by timon.gehr — 2014-04-26T21:44:34Z
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.
Comment #1 by Marco.Leise — 2016-09-17T13:57:34Z
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.
Comment #2 by robert.schadek — 2024-12-13T18:20:10Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18821 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB