Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module level mixin templates conflict #18821

Open
dlangBugzillaToGithub opened this issue Apr 26, 2014 · 1 comment
Open

Module level mixin templates conflict #18821

dlangBugzillaToGithub opened this issue Apr 26, 2014 · 1 comment
Labels

Comments

@dlangBugzillaToGithub
Copy link

timon.gehr reported this on 2014-04-26T21:44:34Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=12659

CC List

  • Marco Leise
  • Vlad Levenfeld

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.
@dlangBugzillaToGithub
Copy link
Author

Marco.Leise commented on 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant