[Issue 10638] Assignment can't be used as a condition

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jul 14 04:58:14 PDT 2013


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


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #2 from bearophile_hugs at eml.cc 2013-07-14 04:58:13 PDT ---
(In reply to comment #1)

> I believe the primary reason is to prevent bugs where == was meant and not =.
> Usually, what you want to do is:
> 
> void main()
> {
>     int i = f();
>     if (i == 1)
>     {
>         //......
>     }
> }

Right. D is working as designed here, it helps avoid bugs.



> Also dlang.org defines ifStatement as "if ( IfCondition ) ThenStatement",
> where ifCondition can be Expression (hence AssignExpression too),
> but it seems it does not work at practice.

Then maybe that's what needs fixing.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list