bugzilla.mozilla.org has resumed normal operation. Attachments prior to 2014 will be unavailable for a few days. This is tracked in Bug 1475801.
Please report any other irregularities here.

JS warning "anonymous function does not always return a value" resource:///modules/devtools/framework/target.js:218

RESOLVED FIXED in Firefox 24

Status

DevTools
Debugger
P3
normal
RESOLVED FIXED
5 years ago
a month ago

People

(Reporter: dholbert, Assigned: past)

Tracking

Trunk
Firefox 24

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

5 years ago
I noticed this in the output of my debug build today (not sure exactly what triggered it, but that doesn't really matter because the warning is pretty clear on its own):
{
JS Component Loader: WARNING resource://gre/modules/commonjs/toolkit/loader.js -> resource:///modules/devtools/framework/target.js:218
                     anonymous function does not always return a value
}

The code in question is:
> 218   get window() {
> 219     // Be extra careful here, since this may be called by HS_getHudByWindow
> 220     // during shutdown.
> 221     if (this._tab && this._tab.linkedBrowser) {
> 222       return this._tab.linkedBrowser.contentWindow;
> 223     }
> 224   },
https://mxr.mozilla.org/mozilla-central/source/browser/devtools/framework/target.js?rev=aeb0f8faf02b#218

...which, as the warning says, does not always return a value. (It's only got one return statement, which is inside of an "if".)

The function used to be an unconditional return (& hence not trigger this warning), but it was changed to its current form here:
 https://hg.mozilla.org/mozilla-central/rev/ca621a4ceaa1#l4.124
for bug 820524. (back when the file was named Target.jsm -- it's been renamed to target.js since then)

CC'ing :past and :jwalker (author and reviewer on that cset), in the hopes that at least one of you might know what the correct fix for this is. :)
(Reporter)

Comment 1

5 years ago
(In reply to Daniel Holbert [:dholbert] from comment #0)
> CC'ing :past and :jwalker (author and reviewer on that cset), in the hopes
> that at least one of you might know what the correct fix for this is. :)

er, now CC'ing for real.
Blocks: 820524
Flags: needinfo?(past)
(Assignee)

Comment 2

5 years ago
Created attachment 751585 [details] [diff] [review]
Patch v1

I hate these warnings.
Assignee: nobody → past
Status: NEW → ASSIGNED
Attachment #751585 - Flags: review?(jwalker)
Flags: needinfo?(past)
Attachment #751585 - Flags: review?(jwalker) → review+
(Assignee)

Comment 3

5 years ago
https://hg.mozilla.org/integration/fx-team/rev/69598cd0437c
Priority: -- → P3
Whiteboard: [fixed-in-fx-team]
https://hg.mozilla.org/mozilla-central/rev/69598cd0437c
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 24

Updated

a month ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.