Open Bug 1275051 Opened 8 years ago Updated 23 days ago

"Mistyped as assignment" warning for while statements

Categories

(DevTools :: Console, defect)

defect

Tracking

(Not tracked)

People

(Reporter: fs, Unassigned)

Details

Looks like there is a lot code in the wild like:

  while(n=n.nextSibling) (jQuery)

With JavaScript strict warnings enabled, the console emits this warning quite often:

  SyntaxError: test for equality (==) mistyped as assignment (=)?

While only a few might have strict warnings enabled, it seems that people notice this [1] and find workarounds for it [2].

[1] 
http://stackoverflow.com/questions/8339601/why-are-there-lots-of-warnings-in-the-firefox-devtools-and-firebug-console
https://github.com/jquery/jquery/issues/2236
https://bugs.jquery.com/ticket/5753
http://www.howtocreate.co.uk/strictJSFirefox.html

[2] 
https://hg.mozilla.org/integration/mozilla-inbound/rev/75c66fa0109e
https://github.com/mathjax/MathJax/issues/1173

So far error telemetry says "JSMSG_EQUAL_AS_ASSIGN" is the 3rd most common error seen in the console.

I think this is useful for `if (foo = bar)`, but wondering if we warn on purpose for the while case... 

Thoughts?
I think it would be weird to warn about `if` but not `while`. This is a classic family of warnings that should be present or absent as a group.

If the warning isn't useful, we should remove it entirely.

Another option is for the devtools console to ignore warnings that occur in blackboxed scripts.
Severity: normal → S3

To Jason's point, to me the warning feels useful in normal JS code, but minified or otherwise library code perhaps ought to be suppressed.

Component: JavaScript Engine → Console
Product: Core → DevTools
You need to log in before you can comment on or make changes to this bug.