Closed Bug 1300416 Opened 7 years ago Closed 6 years ago

Default destructuring logs a "reference to undefined property" strict warning

Categories

(Core :: JavaScript Engine, defect, P3)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1455179

People

(Reporter: lina, Unassigned)

References

Details

(Keywords: triage-deferred)

Using default destructuring in an xpcshell test (or with `javascript.options.strict` enabled) prints a warning if the object on the right-hand side doesn't have the property. For example, the following:

    function acceptsDefaults(options = {}) {
      let { sprinkles = "chocolate" } = options;
      return sprinkles;
    }
    
    acceptsDefaults();

...Prints "JavaScript Warning: ReferenceError: reference to undefined property options.sprinkles" to the console.

This breaks tests that call into a JSM with a function like that, then listen for console output (http://searchfox.org/mozilla-central/rev/3582398bc9db5a83e25c2a8299cc780a52ad7ca8/browser/components/places/tests/unit/head_bookmarks.js#71-98, for instance).

While we can (and probably should) fix the test to filter out logged JS warnings, I'm wondering if the warning is needed for this case at all. ISTM code that provides a default value for destructuring expects that the property not be present.
See Also: → 1366829
Keywords: triage-deferred
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.