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

obj.await should not throw error. #258

Closed
mysticatea opened this issue Mar 14, 2016 · 4 comments
Closed

obj.await should not throw error. #258

mysticatea opened this issue Mar 14, 2016 · 4 comments
Assignees

Comments

@mysticatea
Copy link
Member

From eslint/eslint#5564
On v3.1.1.

In obj.await case, await should not throw a syntax error because this await is IdentifierName (a reserved word is allowed).
Acorn has succeeded to parse it.
I guess this error caused by this line.

"use strict";

const espree = require("espree");
const ast = espree.parse(
    `obj.await`,
    {
        ecmaVersion: 6,
        sourceType: "module"
    }
);

console.log(JSON.stringify(ast, null, 4));
SyntaxError: Unexpected token await
    at Parser.instance.raise.instance.raiseRecoverable (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\espree\espree.js:394:19)
    at Parser.instance.unexpected (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\espree\espree.js:427:14)
    at Parser.esprimaFinishNode (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\espree\espree.js:142:14)
    at Parser.finishNode (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\espree\espree.js:232:34)
    at Parser.pp.parseIdent (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\acorn\dist\acorn.js:678:15)
    at Parser.pp.parseSubscripts (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\acorn\dist\acorn.js:236:28)
    at Parser.pp.parseExprSubscripts (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\acorn\dist\acorn.js:228:15)
    at Parser.pp.parseMaybeUnary (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\acorn\dist\acorn.js:204:17)
    at Parser.pp.parseExprOps (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\acorn\dist\acorn.js:151:19)
    at Parser.pp.parseMaybeConditional (C:\Users\t-nagashima.AD\Documents\GitHub\eslint\node_modules\acorn\dist\acorn.js:133:19)
@nzakas
Copy link
Member

nzakas commented Mar 14, 2016

I think you're right. I did this initially because Acorn wasn't properly handling await as a reserved word in modules. Maybe it's OK now.

@xjamundx
Copy link
Contributor

I may be able to look at this this week assuming it's removing that check and just making sure the tests don't break

@nzakas
Copy link
Member

nzakas commented Mar 14, 2016

Should be

@xjamundx xjamundx self-assigned this Mar 14, 2016
@nzakas
Copy link
Member

nzakas commented Mar 14, 2016

I'm in here looking at other changes, so I'm going to take a look at this while I have the hood up.

@nzakas nzakas closed this as completed in 5783282 Mar 14, 2016
nzakas added a commit that referenced this issue Mar 14, 2016
Fix: Make obj.await work in modules (fixes #258)
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