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

Properties after an async method gets "Parsing error" #298

Closed
daltones opened this issue Sep 28, 2016 · 2 comments
Closed

Properties after an async method gets "Parsing error" #298

daltones opened this issue Sep 28, 2016 · 2 comments
Assignees

Comments

@daltones
Copy link

ESLint: v3.6.1
ECMAVersion: 2017

This code:

var foo = {
  async bar() {
    await 1;
  },
  baz: true
};

Outputs this:

<text>
  5:6  error  Parsing error: Unexpected token :

✖ 1 problem (1 error, 0 warnings)

The problem occurs just with regular properties declared after a async method.

It can be reproduced with:

echo 'var foo = {async bar(){await 1;}, baz: true};' | eslint --no-eslintrc --stdin --parser-options='ecmaVersion:2017'
@xjamundx
Copy link
Contributor

xjamundx commented Sep 29, 2016

Verified in 3.3.1

> require('./espree.js').parse('var foo = { async bar() { await 1}, baz: true }', { ecmaVersion: 8 })
SyntaxError: Unexpected token :
    at Parser.instance.raise.instance.raiseRecoverable (/Users/jamuferguson/dev/espree/espree.js:406:19)
    at Parser.instance.unexpected (/Users/jamuferguson/dev/espree/espree.js:439:14)
    at Parser.pp$3.parsePropertyValue (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:2140:12)
    at Parser.instance.parseObj (/Users/jamuferguson/dev/espree/espree.js:389:18)
    at Parser.pp$3.parseExprAtom (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:1930:19)
    at Parser.pp$3.parseExprSubscripts (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:1817:21)
    at Parser.pp$3.parseMaybeUnary (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:1794:19)
    at Parser.pp$3.parseExprOps (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:1736:21)
    at Parser.pp$3.parseMaybeConditional (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:1719:21)
    at Parser.pp$3.parseMaybeAssign (/Users/jamuferguson/dev/espree/node_modules/acorn/dist/acorn.js:1696:21)

works in acorn

> require('acorn').parse('var foo = { async bar() { await 1}, baz: true }', { ecmaVersion: 8 })
Node {
  type: 'Program',
  start: 0,
  end: 47,
  body: 
   [ Node {
       type: 'VariableDeclaration',
       start: 0,
       end: 47,
       declarations: [Object],
       kind: 'var' } ],
  sourceType: 'script' }

@xjamundx
Copy link
Contributor

Also verified properties before work fine.

> require('./espree.js').parse('var foo = { eggs: true, async bar() { await 1 } }', { ecmaVersion: 8 })
Node {

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

4 participants