First, I would not recommend using a bare template to instantiate an object / structure, because you essentially need the object to be CTFE-capable. If you need an instance, the best option is to return it from the template function:
@property S!(a, b) s(int a, int b)() { return S!(a, b)(); }
However, this does not seem to work with the template constraint. I think this should be a foreground mistake. From what I can say, it seems that the return type cannot be correctly checked in the is () expression if it has not already been created somewhere else, for example:
struct S(int x, int y) { void fun(T)(T t) if (is(TU == S!(a, b), int a, int b)) { } } @property S!(a, b) s(int a, int b)() { return S!(a, b)(); } void main() { auto s1 = S!(1, 1)(); auto s2 = S!(2, 2)();
I will write this as a mistake.
Edit: Filed as Issue 8493 .
source share