www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - bogus cast errors?

reply "Kris" <fu bar.com> writes:
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
parent "Walter" <newshound digitalmars.com> writes:
Yeah, that ain't right. I'll fix it.
Apr 09 2005