question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Parenthesized destructuring assignment should error

See original GitHub issue

Was working with @hzoo on trying to get babel-eslint’s tests running with the ESLint test suite and came across this in our test suite. This passes in ESLint using Espree, but Babylon (babel-eslint’s parser) throws with the following error:

You’re trying to assign to a parenthesized expression, eg. instead of ({a}) = 0 use ({a} = 0)

I did a little digging, and it does seem like this shouldn’t be parsed by Espree. Some findings that back this up:

I also tested in Chrome: screen shot 2016-06-26 at 11 15 40 pm

and Firefox: screen shot 2016-06-26 at 11 16 28 pm

If this is accepted I’ll also file an issue for Espree (and probably ultimately Acorn as well), but I wanted to have an issue open here so we could discuss and track this issue as well as fix the tests if and when this gets fixed in the parser.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
kaicataldocommented, Jun 27, 2016
0reactions
not-an-aardvarkcommented, Apr 22, 2017

Closing because this was fixed in acorn@4.0.5.

Read more comments on GitHub >

github_iconTop Results From Across the Web

4662 - Parenthesized patterns in destructuring assignment - v8
Issue 4662 : Parenthesized patterns in destructuring assignment ... I would expect that parentheses around patterns (at least in assignments, if ...
Read more >
SyntaxError: Invalid destructuring assignment target or ...
It is a Syntax Error if LeftHandSideExpression is neither an ObjectLiteral nor an ArrayLiteral and IsValidSimpleAssignmentTarget( ...
Read more >
Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from ...
Read more >
declaration or statement expected. this '=' follows a block of ...
Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need...
Read more >
Destructuring assignment - OnlyKiosk Dev Tech - Medium
Destructuring assignment also works with objects. But you need to wrap the assignment expression using a set of parenthesis.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found