[Issue 10556] New: mixin template fails overload resolution

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jul 6 07:06:04 PDT 2013


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

           Summary: mixin template fails overload resolution
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2013-07-06 07:06:03 PDT ---
--------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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list