digitalmars.D - bogus cast errors?
void main()
{
char[] s;
char[] t;
if (true)
s = null;
s = (true) ? null : t;
}
"test.d(8): cannot implicitly convert expression (1 ? null : cast(void*)(t))
of type void* to char[]"
You could be forgiven for thinking the error is talking about 't'. But it's
actually talking about the assignment of null instead. This works as
expected:
s = (true) ? cast(char[]) null : t;
But you've got to explicitly cast the null. Yet, the "more traditional"
assignment, on line 7, is accepted without error. What's the deal here?
Apr 08 2005








"Walter" <newshound digitalmars.com>