Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object rest and destructured params #213

Closed
xjamundx opened this issue Nov 13, 2015 · 3 comments
Closed

object rest and destructured params #213

xjamundx opened this issue Nov 13, 2015 · 3 comments

Comments

@xjamundx
Copy link
Contributor

We currently support:
var {a, ...b} = c;

But not:
function b({a, ...b}) {}

babylon and babel-eslint support that syntax instead per http://felix-kling.de/esprima_ast_explorer/ though acorn does not.

@xjamundx
Copy link
Contributor Author

Rough stack trace

TypeError: Cannot read property 'type' of undefined at reinterpretAsDestructuredParameter
 (http://eslint.org/js/app/eslint.js:5674:13) at reinterpretAsDestructuredParameter 
(http://eslint.org/js/app/eslint.js:5681:13) at reinterpretAsCoverFormalsList 
(http://eslint.org/js/app/eslint.js:5512:13) at parseAssignmentExpression 
(http://eslint.org/js/app/eslint.js:5749:22) at parseExpression
(http://eslint.org/js/app/eslint.js:5787:16) at parseExpressionStatement 
(http://eslint.org/js/app/eslint.js:5982:16) at parseStatement 
(http://eslint.org/js/app/eslint.js:6514:44) at parseSourceElement 
(http://eslint.org/js/app/eslint.js:7400:16) at parseSourceElements 
(http://eslint.org/js/app/eslint.js:7433:25) at parseProgram
(http://eslint.org/js/app/eslint.js:7453:12)

@xjamundx
Copy link
Contributor Author

From the issue200 branch it works beautifully:

> require('./espree').parse('function x({a, ...b}) { }', { ecmaFeatures: { destructuring: true, experimentalObjectRestSpread: true}})
{ type: 'Program',
  body: 
   [ { type: 'FunctionDeclaration',
       id: [Object],
       generator: false,
       expression: false,
       params: [Object],
       body: [Object] } ],
  sourceType: 'script' }

@nzakas
Copy link
Member

nzakas commented Dec 1, 2015

Working on this.

@nzakas nzakas closed this as completed in 8aa05fa Dec 1, 2015
nzakas added a commit that referenced this issue Dec 1, 2015
Fix: Ensur object rest works in destructed arg (fixes #213)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants