Limited type matching?

Namespace rswhite4 at googlemail.com
Mon Sep 9 03:02:53 PDT 2013


On Sunday, 8 September 2013 at 21:11:53 UTC, Namespace wrote:
> Code:
>
> ----
> import std.stdio;
>
> void foo(short x, short y) { }
> void foo(short[2] xy) { }
>
> void main()
> {
> 	foo(1, 2); /// works
> 	foo([1, 2]); /// works
> 	
> 	ushort[2] xy = [1, 2];
> 	foo(xy); /// fails
> 	
> 	ushort x = 1, y = 2;
> 	foo(x, y); /// works
> }
> ----
>
> What is the problem? If the compiler is able to cast implicit 
> from ushort to short, what is the problem of casting ushort[2] 
> to short[2]?

Ok I fill a bug for that...


More information about the Digitalmars-d-learn mailing list