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

Bad diagnostic when template has alias overloads #18620

Open
dlangBugzillaToGithub opened this issue Jul 3, 2013 · 0 comments
Open

Bad diagnostic when template has alias overloads #18620

dlangBugzillaToGithub opened this issue Jul 3, 2013 · 0 comments

Comments

@dlangBugzillaToGithub
Copy link

Andrej Mitrovic (@AndrejMitrovic) reported this on 2013-07-03T18:59:28Z

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

Description

-----
struct S1
{
    T get(T)() if (is(T == float)) { }
}

struct S2
{
    auto get(alias value)()
    {
        return S1.get!(typeof(value));
    }
}

struct S3
{
    auto get(alias value)()
    {
        return get!(typeof(value));
    }

    T get(T)() if (is(T == float))
    {
        return T.init;
    }
}

void main()
{
    // Error: template instance get!int does not match template declaration get(T)() if (is(T == float))
    S1.get!int;

    // Error: template instance get!int does not match template declaration get(T)() if (is(T == float))
    S2.get!1;

    // Error: cannot resolve type for this.get!int
    S3.get!1;
}
-----

Observations:

S2.get calls into S1.get, and creates a nice error message. However in S3 the get templates are overloaded against each other, and this causes the diagnostic to become bad. S3.get should have the same diagnostic as S2.get.
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