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

Esprima cannot parse class method named `async get()` #1875

Closed
rilut opened this Issue Nov 4, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@rilut

rilut commented Nov 4, 2017

Steps to reproduce

It fails when async keyword meets get keyword:

esprima.parseScript(`class UserRepo{
    async get(id) {
        return id;
    }
}`)

But these are okay:

(async, not named get)

esprima.parseScript(`class UserRepo{
    async notget(id) {
        return id;
    }
}`)

(not async, named get)

esprima.parse(`(class UserRepo{
    get(id) {
        return id;
    }
})`)

Expected output

Script {
  type: 'Program',
  body:
   [ ClassDeclaration {
       type: 'ClassDeclaration',
       id: [Object],
       superClass: null,
       body: [Object] } ],
  sourceType: 'script' }

Actual output

Error: Line 2: Unexpected identifier
    at ErrorHandler.constructError (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:5004:22)
    at ErrorHandler.createError (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:5020:27)
    at Parser.unexpectedTokenError (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:1985:39)
    at Parser.tolerateUnexpectedToken (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:1998:42)
    at Parser.parseClassElement (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:4587:35)
    at Parser.parseClassElementList (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:4658:33)
    at Parser.parseClassBody (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:4666:33)
    at Parser.parseClassExpression (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:4695:31)
    at Parser.parsePrimaryExpression (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:2380:38)
    at Parser.inheritCoverGrammar (/Users/rilut/myproject/node_modules/esprima/dist/esprima.js:2278:37)
@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Nov 4, 2017

@rilut A quick look at all the reported issues and lack of responses from the mainainers during the last months - I think Esprima is stall now so most likely, this will not be fixed., Maybe try to use Acorn, Cherow or ShiftJS? I moved all my projects long time ago.

ghost commented Nov 4, 2017

@rilut A quick look at all the reported issues and lack of responses from the mainainers during the last months - I think Esprima is stall now so most likely, this will not be fixed., Maybe try to use Acorn, Cherow or ShiftJS? I moved all my projects long time ago.

@mikesherov

This comment has been minimized.

Show comment
Hide comment
@mikesherov

mikesherov Nov 4, 2017

Member

Thanks for the report! Esprima doesn’t yet support async/await.

Member

mikesherov commented Nov 4, 2017

Thanks for the report! Esprima doesn’t yet support async/await.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Nov 4, 2017

@rilut Esprima 4.0 supports async/await. Not sure why @mikesherov wrote that, but you find it in the changelog. The two first bullet points.

ghost commented Nov 4, 2017

@rilut Esprima 4.0 supports async/await. Not sure why @mikesherov wrote that, but you find it in the changelog. The two first bullet points.

@mikesherov

This comment has been minimized.

Show comment
Hide comment
@mikesherov

mikesherov Nov 4, 2017

Member

@crazyhuggins is right.

Member

mikesherov commented Nov 4, 2017

@crazyhuggins is right.

@icefapper

This comment has been minimized.

Show comment
Hide comment
@icefapper

icefapper Nov 30, 2017

@mikesherov @michaelficarra
using my own parser, Jazzle, I had come across (and reported!) this error (and a couple other ones) about a year ago -- #1699

icefapper commented Nov 30, 2017

@mikesherov @michaelficarra
using my own parser, Jazzle, I had come across (and reported!) this error (and a couple other ones) about a year ago -- #1699

@ariya ariya self-assigned this Jun 10, 2018

@ariya ariya added the defect label Jun 10, 2018

ariya added a commit to ariya/esprima that referenced this issue Jun 10, 2018

@ariya ariya closed this in c0dfa42 Jun 15, 2018

ariya added a commit to ariya/esprima that referenced this issue Jun 15, 2018

ariya added a commit to ariya/esprima that referenced this issue Jun 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment