Thread overview | |||||
---|---|---|---|---|---|
|
April 09, 2005 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? |
April 09, 2005 Re: bogus cast errors? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | Yeah, that ain't right. I'll fix it. |
April 09, 2005 Re: bogus cast errors? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kris | -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kris schrieb am Fri, 8 Apr 2005 22:33:34 -0700: > 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? Added to DStress as http://dstress.kuehne.cn/run/cast_25.d http://dstress.kuehne.cn/run/cast_26.d http://dstress.kuehne.cn/run/cast_27.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCV5xW3w+/yD4P9tIRAlafAKCYGMCbyX7qACkUBrK0AHbGZOVn8QCfUn3S B3KhsIqYn8/cBj3jgETW32w= =kslh -----END PGP SIGNATURE----- |
Copyright © 1999-2021 by the D Language Foundation