Closed
Bug 1342837
Opened 7 years ago
Closed 7 years ago
Destructuring second parameter with default value throws SyntaxError
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 1204024
People
(Reporter: andrewli357, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Steps to reproduce: The following code, tested in Firefox 50.0.2 and 51.0.1: const foo = (x, { y = "bar" }) => console.log(x, y); foo("foo", {}); Actual results: The actual result was a SyntaxError: SyntaxError: missing : after property id Seems like it's mistaking { y = "bar" } as an object literal and not a destructured parameter with a default value. Without the default value it works fine. Expected results: I would have expected the following result: foo("foo", {}); //foo bar I also tried: const foo = (x, { y: y } = { y: "bar" }) => console.log(x, y); As suggested here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters#Destructured_parameter_with_default_value_assignment but it did not produce the desired result. But the following: const foo = (x, { y = "bar" } = {}) => console.log(x, y); Works perfectly.
Comment 1•7 years ago
|
||
it's fixed in bug 1204024 (firefox 52)
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•