Closed Bug 1300416 Opened 5 years ago Closed 3 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
Duplicate of this bug: 1448554
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 1455179
You need to log in before you can comment on or make changes to this bug.