Issue 1157 in google-caja: Linter warns on use of Boolean expressions as conditionals

0 views
Skip to first unread message

googl...@googlecode.com

unread,
Nov 13, 2009, 5:50:50 PM11/13/09
to google-ca...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Low

New issue 1157 by ihab.awad: Linter warns on use of Boolean expressions as
conditionals
http://code.google.com/p/google-caja/issues/detail?id=1157

If I add to some of the files we now lint, like say cajita.js, the code:

(function() {
function foo(x) {
!!x && x();
}
})();

I get the messages:

[genrule] WARNING : cajita.js:35+5 - 15: Operation has no effect
[genrule] cajita.js:35: !!x && x();
[genrule] ^^^^^^^^^^
[genrule] 1 NO_SIDE_EFFECT


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

googl...@googlecode.com

unread,
Nov 16, 2009, 7:30:06 PM11/16/09
to google-ca...@googlegroups.com

Comment #1 on issue 1157 by mikesamuel: Linter warns on use of Boolean
I fixed some of the side-effect checks and improved the error message in a
pending CL.

That should address this immediate issue. In the meantime, you can rewrite
this as
if (x) { x(); }

But I don't plan on allowing comma operators as expression statements,
since comma
can be mistaken for semicolon easily which makes for harder to review code.

googl...@googlecode.com

unread,
Nov 16, 2009, 7:34:14 PM11/16/09
to google-ca...@googlegroups.com
Updates:
Status: Accepted
Owner: mikesamuel

Comment #2 on issue 1157 by mikesamuel: Linter warns on use of Boolean
(No comment was entered for this change.)

googl...@googlecode.com

unread,
Jan 19, 2010, 7:41:56 PM1/19/10
to google-ca...@googlegroups.com
Updates:
Status: Fixed

Comment #3 on issue 1157 by mikesamuel: Linter warns on use of Boolean

Reply all
Reply to author
Forward
0 new messages