[Issue 2532] '=' does not give a boolean result

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Dec 21 13:35:58 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2532





------- Comment #3 from ddparnell at bigpond.com  2008-12-21 15:35 -------
The text of the message is not true if the variable being assigned to is
ALREADY a bool. I know that the syntax form 'if (a = b)' is to avoided, but to
say that, IN THIS CASE, the result is not a boolean is plainly wrong.

bool a;
bool b;
b = (a = true); // A boolean expression (a = true) is used to assign to 'b'.

As we know that (a = b) is a boolean expression, it seems wrong to say that it
is a boolean EXCEPT in an 'if' construct. We do this to no other data type.

So maybe the wording of the message can be changed to reflect what is actually
being disallowed. Something like ...
"The syntax form 'if (a = b)' is not allowed".
That takes the argument away from the datatype issue and makes it a syntax
issue instead.


-- 



More information about the Digitalmars-d-bugs mailing list