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

Incorrect parse error for async methods with keywords as names #584

Closed
not-an-aardvark opened this issue Aug 25, 2017 · 4 comments
Closed

Comments

@not-an-aardvark
Copy link
Contributor

When parsing an async method in an object that has a keyword as a name, acorn incorrectly reports a parsing error. This only seems to apply when parsing object methods -- class methods are parsed correctly.

Using acorn 5.1.1:

require('acorn').parse('({ async delete() {} })', { ecmaVersion: 8 });
Expected AST
{
  "type": "Program",
  "start": 0,
  "end": 20,
  "body": [
    {
      "type": "ExpressionStatement",
      "start": 0,
      "end": 20,
      "expression": {
        "type": "ObjectExpression",
        "start": 1,
        "end": 19,
        "properties": [
          {
            "type": "Property",
            "start": 2,
            "end": 18,
            "method": true,
            "shorthand": false,
            "computed": false,
            "key": {
              "type": "Identifier",
              "start": 8,
              "end": 14,
              "name": "delete"
            },
            "kind": "init",
            "value": {
              "type": "FunctionExpression",
              "start": 14,
              "end": 18,
              "id": null,
              "generator": false,
              "expression": false,
              "async": true,
              "params": [],
              "body": {
                "type": "BlockStatement",
                "start": 16,
                "end": 18,
                "body": []
              }
            }
          }
        ]
      }
    }
  ],
  "sourceType": "script"
}
Actual result
SyntaxError: Unexpected token (1:9)

This was originally reported in eslint/eslint#9153.

@not-an-aardvark
Copy link
Contributor Author

Thanks for fixing!

@Standard8
Copy link

@marijnh Would it be possible to get a new release including this fix? We have issues that we want to resolve with dependencies, but this fix is blocking us.

@marijnh
Copy link
Member

marijnh commented Sep 4, 2017

I've tagged 5.1.2

@Standard8
Copy link

Thank you!

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