Closed
Bug 1048598
Opened 11 years ago
Closed 11 years ago
Terminal-spew: "System JS : WARNING resource://gre/modules/commonjs/toolkit/loader.js:410 - test for equality (==) mistyped as assignment (=)?"
Categories
(Add-on SDK Graveyard :: General, defect, P2)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: dholbert, Assigned: evold)
Details
Attachments
(1 file)
Noticed these go by in my terminal-spew, on my debug Firefox build today (using mozilla-central):
{
System JS : WARNING resource://gre/modules/commonjs/toolkit/loader.js:410 - test for equality (==) mistyped as assignment (=)?
System JS : WARNING resource://gre/modules/commonjs/toolkit/loader.js:412 - test for equality (==) mistyped as assignment (=)?
System JS : WARNING resource://gre/modules/commonjs/toolkit/loader.js:419 - test for equality (==) mistyped as assignment (=)?
System JS : WARNING resource://gre/modules/commonjs/toolkit/loader.js:421 - test for equality (==) mistyped as assignment (=)?
System JS : WARNING resource://gre/modules/commonjs/toolkit/loader.js:462 - test for equality (==) mistyped as assignment (=)?
}
This is for code like...
> 409 let resolvedPath;
> 410 if (resolvedPath = loadAsFile(fullId))
> 411 return stripBase(rootURI, resolvedPath);
http://mxr.mozilla.org/mozilla-central/source/addon-sdk/source/lib/toolkit/loader.js#409
...and it looks like the assignment is intentional, so the warnings are spurious.
I suspect we can silence the warnings by adding another layer of parenthesis. That works for the equivalent warning in GCC, at least. (It's a hint to the compiler/interpreter "Yes, this is an assignment; this extra layer of parenthesis indicates that I'm interpreting the result of the assignment as a boolean condition.")
Comment 1•11 years ago
|
||
this doesn't happen in non-debug builds, right?
(that's a 7 months old "uplift sdk" bug, we have a new one each week)
No longer blocks: 956129
| Reporter | ||
Comment 2•11 years ago
|
||
I believe this is debug-only, yes.
| Assignee | ||
Updated•11 years ago
|
Assignee: nobody → evold
| Assignee | ||
Comment 3•11 years ago
|
||
Attachment #8467499 -
Flags: review?(jsantell)
Comment 4•11 years ago
|
||
The if/elses are intentional -- only one of the statements should run, by checking the validity of the resolution after each attempt. With these changes, if it can load via directory, that'll replace the first `if` of loading it as a file. This means if we have a `require("./x")`, it should first attempt to load x.js, and then x/ as a dir. If both exist, this means it'll default to a directory rather than a file -- this is not what we want. Not to mention the last previous `else` attempts to look it up as a node_modules dependency, which this will always do. I think this will fail tests if we test for these cases, which I believe we do.
The parentheses changes look fine to quell the warning messages, though, but pretty sure the `else` removing will break.
Comment 5•11 years ago
|
||
Additionally, I think the ifs in the node module lookup loop should be if/else if for the same reasons, but guessing we don't have a test case where a node_module is using require("./x") where x is both a js file and a directory
| Reporter | ||
Comment 6•11 years ago
|
||
You seem to be saying that the "else" keywords affect the logic here -- but I don't think that's possible, since else-after-return is strictly unnecessary. At least, the first entry in the Mozilla Coding Style C++ is the following:
> Don't put an else right after a return. Delete the else,
> it's unnecessary and increases indentation level.
https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style
Of course, this bug here is about JS, not C++, but (unless I'm missing some fancy JS feature) this C++ guideline should be equally true of JS.
| Reporter | ||
Updated•11 years ago
|
Flags: needinfo?(jsantell)
Comment 7•11 years ago
|
||
You're right -- didn't notice the return
**coffee**
Flags: needinfo?(jsantell)
I missed this and filed bug 1049312 yesterday. It takes a different approach (it merely adds the extra parenthesis) and also fixes a couple of other things.
If Erik's pull request is merged, I'll rebase my pull request for the the other warnings.
Updated•11 years ago
|
Priority: -- → P2
Updated•11 years ago
|
Attachment #8467499 -
Flags: review?(jsantell) → review+
| Reporter | ||
Comment 9•11 years ago
|
||
Looks like poiru's fix for this (on bug 1049312) was already merged, per bug 1049312 comment 2.
So, as-filed, this bug can be resolved as a dupe of bug 1049312.
(However, we probably should still land the "fix else-after-return" aspect of the patch that we had here. Erik, feel free to just retarget this bug to be about that, if you like; or, maybe you'd prefer to spin off a separate bug for that.)
Flags: needinfo?(evold)
Comment 10•11 years ago
|
||
Commit pushed to master at https://github.com/mozilla/addon-sdk
https://github.com/mozilla/addon-sdk/commit/24162a4fa5e91c28be395e56beeac0f7e2e818c3
Bug 1048598 removing an unnecessary else statement r=@jsantell
| Assignee | ||
Updated•11 years ago
|
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(evold)
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•