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

Using Object shorthand with a prop named "async" results in a parse error #340

Closed
muffinresearch opened this issue Jun 7, 2017 · 3 comments · Fixed by #341
Closed

Using Object shorthand with a prop named "async" results in a parse error #340

muffinresearch opened this issue Jun 7, 2017 · 3 comments · Fixed by #341

Comments

@muffinresearch
Copy link

Here's a reduced test case that generates the error:

/* global console */

const async = false;
const bar = 1;
const foo = { async, bar };

console.log(foo);

Error message is: error Parsing error: Unexpected token ,

Eslint version is: v4.0.0-rc.0
espree: 3.4.3

Using ecmaversion 8.

Changing: const foo = { async, bar }; to const foo = { async: async, bar }; prevents the error.

Relates to #295

@mysticatea
Copy link
Member

Thank you for the report.

I confirmed it.
Acorn, the upstream parser of espree, also has the problem.
Additionally, espree overrides the problem method, so we have to fix espree as well.

@ilyavolodin
Copy link
Member

Does acorn even support object spread out of the box? It's still an experimental feature.

@not-an-aardvark
Copy link
Member

It seems like the issue is with object shorthand, not object spreading.

@muffinresearch muffinresearch changed the title Object spreading a prop named "async" results in a parse error Using Object shorthand with a prop named "async" results in a parse error Jun 9, 2017
mysticatea added a commit that referenced this issue Jun 15, 2017
* Fix: async shorthand properties (fixes #340)
* Fix: and default parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants