Limited type matching?
monarch_dodra
monarchdodra at gmail.com
Mon Sep 9 04:44:00 PDT 2013
On Monday, 9 September 2013 at 11:36:42 UTC, Andrej Mitrovic
wrote:
> On 9/8/13, Namespace <rswhite4 at googlemail.com> wrote:
>> 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]?
>
> Oh I didn't even noticed it was a signed/unsigned issue. I'm
> not sure
> whether or not it's a bug. But file it anyways and someone will
> know
> what to do with it.
I think the "issue" is that when you write "[1, 2]", that array
is still "weakly typed", and the compiler will implicitly cast it
to any type that will create a match. Once you've crammed it into
a variable though, it becomes explicitly typed, and the casts
become no-go.
It's kind of like how you can write:
wstring s = "hello!";
I dare say that the behavior is expected.
More information about the Digitalmars-d-learn
mailing list