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

I think fast-async and rest-spread is not incompatible #6

Closed
coudly opened this issue Jul 14, 2016 · 7 comments
Closed

I think fast-async and rest-spread is not incompatible #6

coudly opened this issue Jul 14, 2016 · 7 comments

Comments

@coudly
Copy link

coudly commented Jul 14, 2016

I think fast-async and rest spread is not incompatible
the error sample :

origin es file

(props) => {
  let { ...others } = props
}

babel options

module.exports = {
  "presets": [ "es2015", "stage-2" ],
  "plugins": [
     [require("fast-async"), { runtimePattern: 'directive' }]
  ]
}

exception stack info

"TypeError: Cannot read property 'name' of undefined
    at fast-async\node_modules\nodent\lib\arboriculture.js:2004:63
    at Array.map (native)
    at getDeclNames (fast-async\node_modules\nodent\lib\arboriculture.js:2004:34)
    at fast-async\node_modules\nodent\lib\arboriculture.js:2050:29
    at treeWalker (fast-async\node_modules\nodent\lib\parser.js:156:5)
    at goDown (fast-async\node_modules\nodent\lib\parser.js:122:9)
    at down (fast-async\node_modules\nodent\lib\parser.js:146:25)
    at Object.__dirname.1.base.Function (fast-async\node_modules\nodent\node_modules\acorn\dist\walk.js:269:4)
    at down (fast-async\node_modules\nodent\lib\parser.js:133:60)
    at Object.__dirname.1.base.FunctionDeclaration (fast-async\node_modules\nodent\node_modules\acorn\dist\walk.js:253:10)"
@coudly
Copy link
Author

coudly commented Jul 14, 2016

1

debug screenshot

@coudly coudly changed the title I think fast-async and rest spread is not incompatible I think fast-async and rest-spread is not incompatible Jul 14, 2016
@matAtWork
Copy link
Collaborator

Thanks - I'll take a look

@matAtWork
Copy link
Collaborator

It appears that this is not valid ES6 - see acornjs/acorn#388 - Object rest is a babel extension. I'll see if I can patch it up, however support for non-ES6 constructs is not guaranteed as they may change in the future.

matAtWork added a commit that referenced this issue Jul 14, 2016
e.g `var {a,b,...x} = y ;` used in Babel (see
#6)
@matAtWork
Copy link
Collaborator

This should be fixed in https://github.com/MatAtBread/fast-async/releases/tag/6.0.30

Please re-open if you this doesn't fix your issues. Thanks for reporting it.

@mikekasprzak
Copy link

mikekasprzak commented Oct 12, 2017

Best I can tell this only implements Rest. i.e.

let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 };

not Spread

let n = { x, y, ...z };

I haven't done the most thorough testing, but our toolchain is choking on nodents ability to parse spread.

@matAtWork
Copy link
Collaborator

matAtWork commented Oct 13, 2017

[IGNORE THIS - SEE BELOW]
This appears to be a bug in Acorn (the parser used by fast-async/nodent). Acorn adheres strictly to the ECMA spec, and I believe this is an extension - it fails in Babel as well unless you enable the objectRestSpread option (see astexplorer.net), as well as in Esprima, Shift, recast and Traceur.

The current ECMA standard permits the Spread operator in array literals, not object literals.

If you think this is part of the ECMA standard, please post an issue with Acorn I will look into a fix when it has been updated: https://github.com/ternjs/acorn/issues

@matAtWork
Copy link
Collaborator

...actually, this should work with fast-async (rather than nodent), as it uses Babylon (from Babel) as the parser, not acorn. I'll see if I can work out what it's doing in the next few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants