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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4163 - if(bool = bool) results in ill-worded error
Summary: if(bool = bool) results in ill-worded error
Status: RESOLVED DUPLICATE of issue 2532
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
Reported: 2010年05月07日 10:42 UTC by Steven Schveighoffer
Modified: 2014年02月15日 02:45 UTC (History)
2 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Steven Schveighoffer 2010年05月07日 10:42:33 UTC
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 bearophile_hugs 2010年05月08日 04:42:46 UTC
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 yebblies 2011年06月13日 09:01:42 UTC
*** This issue has been marked as a duplicate of issue 2532 ***


AltStyle によって変換されたページ (->オリジナル) /