When a parameter of a closure has no identifier, the type cannot be a type alias, or a custom type (however it can be a static array, slice, or associative array that contains that type)
Here is an example...
//Works, as you'd expect:
pragma(msg, typeof( (int){} )); //`void function(int __param_0) pure nothrow @nogc @safe`
alias I = int;
//Now that we're using an alias to `int`, it gives us an invalid value (i.e. an error occurred):
pragma(msg, typeof( (I){} )); //`void`
//But a slice that contains our alias is totally fine:
pragma(msg, typeof( (I[]){} )); //`void function(int[] __param_0) pure nothrow @nogc @safe`
//Same thing for custom types like structs:
struct S{}
pragma(msg, typeof( (S){} )); //`void`
pragma(msg, typeof( (S[]){} )); //`void function(S[] __param_0) pure nothrow @nogc @safe`
This behaviour is really strange, and makes using templates like update really confusing:
alias I = int;
void main(){
I[int] aa;
aa.update( //OK!
0,
() => I(),
(int) => I(),
);
aa.update( //Error? Huh?? This is exactly the same thing?
0,
() => I(),
(I) => I(),
);
}
When a parameter of a closure has no identifier, the type cannot be a type alias, or a custom type (however it can be a static array, slice, or associative array that contains that type)
Here is an example...
This behaviour is really strange, and makes using templates like
updatereally confusing: