On Tuesday, 1 September 2020 at 01:11:35 UTC, Ben Jones wrote:
I have an alias that looks like
static if(...){
alias AliasType = SumType!(...);
}
which I use in a template constraint for a function template:
bool func(T: AliasType!Args, Args...)(T t){ ... }
When I try to call func with an AliasType object, the argument
deduction fails with a message saying that the argument type (a
SumType) doesn't match the template constraint (an AliasType)
Things do work if I change the template constraint to be a
SumType rather an an AliasType
Is there a workaround to this? Here's a complete example:
https://run.dlang.io/is/buRGTs
This is a very old known bug:
https://issues.dlang.org/show_bug.cgi?id=1807
Attempts have been made to fix it, but the problem is a lot more
complicated than it looks at first glance, so I wouldn't expect a
solution any time soon.
Aside from using SumType directly in the function signature,
another workaround is to use a wrapper struct instead of an alias:
struct AliasType(Args...) {
SumType!Args data;
alias data this;
}
bool func(T : AliasType!Args, Args...)(T t) { ... }