Closed
Bug 382622
Opened 17 years ago
Closed 6 years ago
Expand the "useless expression" strict warning to cover = mistyped as ==
Categories
(Core :: JavaScript Engine, enhancement)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: jruderman, Unassigned)
References
Details
function() { var c; c == 0; } fires the "useless expression" warning, but function() { c == 0; } does not. I think the latter should as well, because even though the subexpression c is useful, the comparison is useless. Bug 382584 contains an example of a bug where an assignment (=) was mistyped as comparison (==). In that instance, the LHS was a local variable, so the warning was able to fire. But if the LHS had been a global variable or a property of something, the existing warning would not have fired.
Assignee | ||
Updated•10 years ago
|
Assignee: general → nobody
Comment 1•8 years ago
|
||
There's a difference between function() { var c; c == 0; } and function() { c == 0; } The second one sets/changes a global variable called 'c', hence it's not a "useless" expression. Working as per Javascript specification. Therefore I suggest to close this bug.
Comment 2•8 years ago
|
||
Indeed, my mistake (I tohught it was c=0;}. c==0 is indeed a useless expression.
Comment 3•8 years ago
|
||
However, if 'c' variable is defined through a getter, then the getter could have side effects. Then that call would not be useless.
Comment 4•6 years ago
|
||
Any local variable access is nowadays considered an effectful expression (see bug 1167823), therefore resolving as WONTFIX.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•