D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10533 - Bad diagnostic when template has alias overloads
Summary: Bad diagnostic when template has alias overloads
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2013-07-03 18:59 UTC by Andrej Mitrovic
Modified: 2024-12-13 18:08 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2013-07-03 18:59:28 UTC
-----
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.
Comment 1 dlangBugzillaToGithub 2024-12-13 18:08:51 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18620

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB