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



--- Comment #6 from Jonathan M Davis <jmdavisp...@gmx.com> 2012-06-29 17:01:10 
PDT ---
> I think you might have missed the second set of parentheses on the first
template function declaration.

Ah, you're right. I did miss those, but it still shouldn't compile, because the
compiler doesn't know which template the programmer was trying to instantiate.
Did they mean the first one (which would then be callable) or the second (which
wouldn't, because it lacks the function arguments that it requires). The
template functions don't even exist to be checked for overloading rules until
they've been instantiated, so overloading rules have no effect here. Remember
that they actually translate to

template lol(string wat)
{
    void lol()
    {
        writeln(wat);
    }
}

template lol(string wat)
{
    void lol(string omg)
    {
        writeln(wat, " ", omg);
    }
}

So, when you say lol!"rulez", which one is the compiler going to pick? It
doesn't know which you mean. The template signatures are identical and have no
template constraints to distinguish them. So, you have a conflict. If you did

template lol(string wat)
{
    void lol()
    {
        writeln(wat);
    }

    void lol(string omg)
    {
        writeln(wat, " ", omg);
    }
}

then it would work (assuming that you didn't compile with -property, since then
you'd have to do lol!"rulez"() rather than lol!"rulez", since the lol function
isn't a property). But with how they're currently declared, you have a conflict
between two templates.

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

Reply via email to