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

ES6 modules cannot use "await" as an identifier #8559

Open
evmar opened this issue May 11, 2016 · 3 comments · May be fixed by #55503
Open

ES6 modules cannot use "await" as an identifier #8559

evmar opened this issue May 11, 2016 · 3 comments · May be fixed by #55503
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec
Milestone

Comments

@evmar
Copy link
Contributor

evmar commented May 11, 2016

According to http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words
"await is only treated as a FutureReservedWord when Module is the goal symbol of the syntactic grammar."

This code should be illegal I think:
http://www.typescriptlang.org/play/#src=import%20'foo'%3B%0A%0Alet%20await%20%3D%203%3B

Came up when discussing TS semantics with @ajklein (v8 ES6 module expert).

@mhegazy mhegazy added Bug A bug in TypeScript ES6 Relates to the ES6 Spec labels May 11, 2016
@mhegazy mhegazy self-assigned this Jun 7, 2016
@mhegazy mhegazy added this to the TypeScript 2.1 milestone Jun 7, 2016
@yortus
Copy link
Contributor

yortus commented Aug 22, 2016

Also note the qualification in section 10.2:

Module code is source text that is code that is provided as a ModuleBody. It is the code that is directly evaluated when a module is initialized. The module code of a particular module does not include any source text that is parsed as part of a nested FunctionDeclaration, FunctionExpression, GeneratorDeclaration, GeneratorExpression, MethodDefinition, ArrowFunction, ClassDeclaration, or ClassExpression.

So the OP's playground example is definitely not allowed, but given the above quote I think the following is allowed in an ES6 module:

export function foo() {
    let await = 3;
}

@bterlson
Copy link
Member

@yortus, await is a reserved whenever the syntactic goal symbol is Module which is when parsing the entire module script. Thus, await is never allowed as an identifier in a module. The Module goal symbol is a distinct concept from "module code". See 5.1.1.

@yortus
Copy link
Contributor

yortus commented Aug 23, 2016

@bterlson thanks for the clarification. So we are losing another identifier to keywordland 😞 Pity it couldn't be treated as a contextual keyword like async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript ES6 Relates to the ES6 Spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants