On Saturday, 17 November 2012 at 18:28:10 UTC, ref2401 wrote:
I get "template instance main.MyClass!(int) error instantiating" in the following case:

public class MyClass(TStuff)
{
        public void foo(TStuff item)
        {}

        public void foo(TRange)(TRange items)
        if (isInputRange!TRange && is(ElementType!TRange == TStuff))
        {}
}

void main(string[] argv)
{
        MyClass!int instance = new MyClass!int();

        return;
}

but if i rename one of the "foo" overloads then code will be compiled.

Full error message is:

Error: template main.MyClass!(int).MyClass.foo(TRange) if (isInputRange!(TRange) && is(ElementType!(TRange) == TStuff)) conflicts with function main.MyClass!(int).MyClass.foo at main.d(3) main.d(13): Error: template instance main.MyClass!(int) error instantiating

That's why renaming foo makes dmd happy. Alternatively you can add extra dummy parenthesis in the first foo to make it template function. This is not the first case I see adding parenthesis to function declarations solves compilation errors.

Reply via email to