Bug 4163 – if(bool = bool) results in ill-worded error

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2010-05-07T10:42:00Z
Last change time
2014-02-15T02:45:47Z
Assigned to
nobody
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2010-05-07T10:42:33Z
The following code: bool x, y; if(x = y) {} results in the following error: Error: '=' does not give a boolean result Which is clearly not a correct message. A better message would be something like: Error: '=' cannot be used inside an if condition
Comment #1 by bearophile_hugs — 2010-05-08T04:42:46Z
Be careful with the wording, because this is allowed in D: if(bool c = !b) Writing a compiler requires literary expression skills :-) A possible error message, that looks too much complex: Error: if(x = y) is now allowed, use if(T x = y) or if((x = y) == z).
Comment #2 by yebblies — 2011-06-13T09:01:42Z
*** This issue has been marked as a duplicate of issue 2532 ***