Summary: Template fails to instantiate with templated argument
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: major
          Priority: P2
         Component: DMD

--- Comment #0 from Andrej Mitrovic <> 2012-05-02 
20:45:48 PDT ---

enum Enum { Foo }
struct Stub { }
template Temp(alias T) { alias Stub Temp; }

struct Foo
    auto call(Enum en)()
        Stub arg;
        return arg;

        void test(Enum en)(Temp!en arg)
            if (0) {}

        void test(Enum en)(Temp!en arg)
            if (1) {}
        void test(Enum en)(Stub arg)
            if (0) {}

        void test(Enum en)(Stub arg)
            if (1) {}

void main()
    Foo foo;!(Enum.Foo)();

This fails with:
test.d(14): Error: template test.Foo.test does not match any function template
test.d(14): Error: template test.Foo.test cannot deduce template function from
argument types !(cast(Enum)0)(Stub)
test.d(40): Error: template instance!(cast(Enum)0) error

You can comment out the test template in the version(Fail) that has this
constraint: "if (0) {}" and it will compile again.

You can also version=Fail to version=Ok then it will compile. The version=Ok
code doesn't instantiate the Temp template and this seems to work. But both
versions should work because both templates resolve the type as a Stub struct.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to