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

mixin template fails overload resolution #18621

Open
dlangBugzillaToGithub opened this issue Jul 6, 2013 · 2 comments
Open

mixin template fails overload resolution #18621

dlangBugzillaToGithub opened this issue Jul 6, 2013 · 2 comments

Comments

@dlangBugzillaToGithub
Copy link

monarchdodra reported this on 2013-07-06T07:06:03Z

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

CC List

  • Ferdinand Majerech

Description

--------mixin template fooImpl(T)
{
    static void foo(T t)
    {}
}
struct S{}
mixin fooImpl!S;
mixin fooImpl!int;
mixin fooImpl!long;

void main()
{
    S s;
    int a;
    foo(s);
    foo(a); //17
}

--------
hello.d
17
Error: hello.fooImpl!(int).foo at hello.d:3 conflicts with hello.fooImpl!(long).foo at hello.d:3
--------

Here, I'm using mixin template fooImpl to create a finite set of non-template functions. In particular, I'm generating the functions "foo(int)" and "foo(long)".

Yet, when making the call to "foo" with an int, the compiler complains of finding multiple matches, failing to "see" that there is an exact match.

Apparently, I think the compiler sees "foo" as template functions "fooImpl!long.foo(long)", so they all equally match. I think this is wrong behavior.

The specs state that "If two different mixins are put in the same scope, and each define a declaration with the same name, there is an ambiguity error when the declaration is referenced", however this is clearly not the case, since "foo(s)" is correctly resolved. foo(int) and foo(long) should also correctly resolve just as well.
@dlangBugzillaToGithub
Copy link
Author

monarchdodra commented on 2013-07-06T07:09:46Z

http://d.puremagic.com/issues/show_bug.cgi?id=8074

8074 is related, although it deals with "strictly non-ambiguous overloads". In this example, there are multiple matches, but one is "exact".

@dlangBugzillaToGithub
Copy link
Author

kiithsacmp commented on 2015-01-01T04:53:34Z

Any progress on this issue? I've just run into it in my code; can work around with a string mixin but the result is much uglier.

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

No branches or pull requests

1 participant