Bug #18214 Updated: Request: Warning on assignment in IF expression.
| From: | tal@php.net | Date: | Tue, 09 Jul 2002 08:58:59 +0000 |
| Subject: | Bug #18214 Updated: Request: Warning on assignment in IF expression. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-13575@lists.php.net to get a copy of this message | ||
ID: 18214
Updated by: tal@php.net
Reported By: djanix@hotmail.com
Status: Feedback
Bug Type: Feature/Change Request
Operating System: any
PHP Version: 4CVS-2002-07-07
New Comment:
IMHO, this behavior shhould not be implemented.
This construct is used widely actually (almost in every script i've
ever written).
And usually warnings imply that something is wrong, while there is
nothing wrong with that.
-Tal
Previous Comments:
------------------------------------------------------------------------
[2002-07-09 02:09:53] philip@php.net
What are some other potential "strict" mode watches? Some people ask
for an optional "strict" mode with various options, this could be a
good start? Imagine a strict mode directive where when on, various
options could be set at runtime, like assignment_inside_expression =
true :)
------------------------------------------------------------------------
[2002-07-08 10:19:16] m.ford@lmu.ac.uk
Rare??? What do you mean, rare???
Nearly every script I write uses this construct multiple times.
Sometimes, it occurs more often than equality comparisons. Changing
this would make my life hell!!
Cheers!
Mike
------------------------------------------------------------------------
[2002-07-07 18:18:31] jan@php.net
on a side note, it is a good practice to swap the 'assignment
arguments':
if ('foo' == $bar), since 'foo' = $bar does produce a warning.
------------------------------------------------------------------------
[2002-07-07 17:55:54] djanix@hotmail.com
right it's legal - but it's so rare that it is usually a mistake, which
is why most c compilers will generate a warning for it. would have
saved me a good 30 minutes tonight spent searching for the cause of a
bug... :(
-benjamin
------------------------------------------------------------------------
[2002-07-07 17:41:10] sniper@php.net
Not possible: if ($xx = some_function()) {} is perfectly
legal.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/18214
--
Edit this bug report at http://bugs.php.net/?id=18214&edit=1