Throw error for reserved words enum and await (#195)

* Throw error for reserved words enum and await when source type is module

* Extract reserved word check into method

* Fix tests
This commit is contained in:
Kai Cataldo 2016-11-09 10:29:02 -05:00 committed by Daniel Tschinder
parent 643124744f
commit e260381e06
189 changed files with 1460 additions and 231 deletions

View File

@ -827,13 +827,7 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync,
if (!prop.computed && prop.key.type === "Identifier") {
if (isPattern) {
let illegalBinding = this.isKeyword(prop.key.name);
if (!illegalBinding && this.state.strict) {
illegalBinding = reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name);
}
if (illegalBinding) {
this.raise(prop.key.start, "Binding " + prop.key.name);
}
this.checkReservedWord(prop.key.name, prop.key.start, true, true);
prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key.__clone());
} else if (this.match(tt.eq) && refShorthandDefaultPos) {
if (!refShorthandDefaultPos.start) {
@ -843,6 +837,7 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync,
} else {
prop.value = prop.key.__clone();
}
prop.shorthand = true;
return this.finishNode(prop, "ObjectProperty");
}
@ -998,8 +993,8 @@ pp.parseIdentifier = function (liberal) {
let node = this.startNode();
if (this.match(tt.name)) {
if (!liberal && this.state.strict && reservedWords.strict(this.state.value)) {
this.raise(this.state.start, "The keyword '" + this.state.value + "' is reserved");
if (!liberal) {
this.checkReservedWord(this.state.value, this.state.start, false, false);
}
node.name = this.state.value;
@ -1019,6 +1014,16 @@ pp.parseIdentifier = function (liberal) {
return this.finishNode(node, "Identifier");
};
pp.checkReservedWord = function (word, startLoc, checkKeywords, isBinding) {
if (this.isReservedWord(word) || (checkKeywords && this.isKeyword(word))) {
this.raise(startLoc, word + " is a reserved word");
}
if (this.state.strict && (reservedWords.strict(word) || (isBinding && reservedWords.strictBind(word)))) {
this.raise(startLoc, word + " is a reserved word in strict mode");
}
};
// Parses await expression inside async function.
pp.parseAwait = function (node) {

View File

@ -11,7 +11,6 @@ export default class Parser extends Tokenizer {
this.options = options;
this.inModule = this.options.sourceType === "module";
this.isReservedWord = reservedWords[6];
this.input = input;
this.plugins = this.loadPlugins(this.options.plugins);
this.filename = options.sourceFilename;
@ -22,6 +21,14 @@ export default class Parser extends Tokenizer {
}
}
isReservedWord(word: string): boolean {
if (word === "await") {
return this.inModule;
} else {
return reservedWords[6](word);
}
}
hasPlugin(name: string): boolean {
return !!(this.plugins["*"] || this.plugins[name]);
}

View File

@ -2,7 +2,6 @@
import { types as tt } from "../tokenizer/types";
import Parser from "./index";
import { reservedWords } from "../util/identifier";
const pp = Parser.prototype;
@ -204,9 +203,7 @@ pp.parseMaybeDefault = function (startPos, startLoc, left) {
pp.checkLVal = function (expr, isBinding, checkClashes, contextDescription) {
switch (expr.type) {
case "Identifier":
if (this.state.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) {
this.raise(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode");
}
this.checkReservedWord(expr.name, expr.start, false, true);
if (checkClashes) {
// we need to prefix this with an underscore for the cases where we have a key of

View File

@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:8)"
}
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:36)"
}
"throws": "eval is a reserved word in strict mode (1:36)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:36)"
}
"throws": "arguments is a reserved word in strict mode (1:36)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:47)"
}
"throws": "eval is a reserved word in strict mode (1:47)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:47)"
}
"throws": "arguments is a reserved word in strict mode (1:47)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:32)"
}
"throws": "eval is a reserved word in strict mode (1:32)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to arguments in strict mode (1:32)"
}
"throws": "arguments is a reserved word in strict mode (1:32)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:34)"
}
"throws": "eval is a reserved word in strict mode (1:34)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:34)"
}
"throws": "eval is a reserved word in strict mode (1:34)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to arguments in strict mode (1:34)"
}
"throws": "arguments is a reserved word in strict mode (1:34)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to arguments in strict mode (1:34)"
}
"throws": "arguments is a reserved word in strict mode (1:34)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:32)"
}
"throws": "eval is a reserved word in strict mode (1:32)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:32)"
}
"throws": "eval is a reserved word in strict mode (1:32)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to arguments in strict mode (1:32)"
}
"throws": "arguments is a reserved word in strict mode (1:32)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to arguments in strict mode (1:32)"
}
"throws": "arguments is a reserved word in strict mode (1:32)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:41)"
}
"throws": "eval is a reserved word in strict mode (1:41)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:41)"
}
"throws": "arguments is a reserved word in strict mode (1:41)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:9)"
}
"throws": "eval is a reserved word in strict mode (1:9)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:9)"
}
"throws": "arguments is a reserved word in strict mode (1:9)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:42)"
}
"throws": "eval is a reserved word in strict mode (1:42)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:42)"
}
"throws": "arguments is a reserved word in strict mode (1:42)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:10)"
}
"throws": "eval is a reserved word in strict mode (1:10)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:10)"
}
"throws": "arguments is a reserved word in strict mode (1:10)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:47)"
}
"throws": "eval is a reserved word in strict mode (1:47)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding package in strict mode (1:10)"
}
"throws": "package is a reserved word in strict mode (1:10)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:48)"
}
"throws": "eval is a reserved word in strict mode (1:48)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:41)"
}
"throws": "eval is a reserved word in strict mode (1:41)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:49)"
}
"throws": "eval is a reserved word in strict mode (1:49)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:15)"
}
"throws": "eval is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:15)"
}
"throws": "arguments is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:48)"
}
"throws": "eval is a reserved word in strict mode (1:48)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:48)"
}
"throws": "arguments is a reserved word in strict mode (1:48)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding implements in strict mode (1:37)"
"throws": "implements is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding interface in strict mode (1:37)"
"throws": "interface is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding package in strict mode (1:37)"
"throws": "package is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding private in strict mode (1:37)"
"throws": "private is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding protected in strict mode (1:37)"
"throws": "protected is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding public in strict mode (1:37)"
"throws": "public is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding static in strict mode (1:37)"
"throws": "static is a reserved word in strict mode (1:37)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding static in strict mode (1:15)"
}
"throws": "static is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding static in strict mode (1:9)"
}
"throws": "static is a reserved word in strict mode (1:9)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "The keyword 'static' is reserved (1:23)"
"throws": "static is a reserved word in strict mode (1:23)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:11)"
}
"throws": "eval is a reserved word in strict mode (1:11)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding package in strict mode (1:11)"
}
"throws": "package is a reserved word in strict mode (1:11)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:12)"
}
"throws": "eval is a reserved word in strict mode (1:12)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding package in strict mode (1:12)"
}
"throws": "package is a reserved word in strict mode (1:12)"
}

View File

@ -0,0 +1,2 @@
"use strict";
const { public } = foo();

View File

@ -0,0 +1,3 @@
{
"throws": "public is a reserved word in strict mode (2:8)"
}

View File

@ -0,0 +1 @@
const { public } = foo();

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "public is a reserved word in strict mode (1:8)"
}

View File

@ -0,0 +1 @@
const { public } = foo();

View File

@ -0,0 +1,172 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 25
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 24
}
},
"id": {
"type": "ObjectPattern",
"start": 6,
"end": 16,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 16
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 8,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 14
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 8,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "public"
},
"name": "public"
},
"value": {
"type": "Identifier",
"start": 8,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "public"
},
"name": "public"
},
"extra": {
"shorthand": true
}
}
]
},
"init": {
"type": "CallExpression",
"start": 19,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 24
}
},
"callee": {
"type": "Identifier",
"start": 19,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 22
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": []
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -0,0 +1,2 @@
"use strict";
const { arguments } = foo();

View File

@ -0,0 +1,3 @@
{
"throws": "arguments is a reserved word in strict mode (2:8)"
}

View File

@ -0,0 +1 @@
const { arguments } = foo();

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "arguments is a reserved word in strict mode (1:8)"
}

View File

@ -0,0 +1 @@
const { arguments } = foo();

View File

@ -0,0 +1,172 @@
{
"type": "File",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"program": {
"type": "Program",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 28,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 28
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 27
}
},
"id": {
"type": "ObjectPattern",
"start": 6,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 19
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 8,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 17
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 8,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "arguments"
},
"name": "arguments"
},
"value": {
"type": "Identifier",
"start": 8,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "arguments"
},
"name": "arguments"
},
"extra": {
"shorthand": true
}
}
]
},
"init": {
"type": "CallExpression",
"start": 22,
"end": 27,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 27
}
},
"callee": {
"type": "Identifier",
"start": 22,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": []
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding this (1:6)"
"throws": "this is a reserved word (1:6)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:44)"
}
"throws": "eval is a reserved word in strict mode (1:44)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:20)"
}
"throws": "eval is a reserved word in strict mode (1:20)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to arguments in strict mode (1:20)"
}
"throws": "arguments is a reserved word in strict mode (1:20)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:15)"
}
"throws": "eval is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:14)"
}
"throws": "eval is a reserved word in strict mode (1:14)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:14)"
}
"throws": "arguments is a reserved word in strict mode (1:14)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:15)"
}
"throws": "eval is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding arguments in strict mode (1:15)"
}
"throws": "arguments is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:15)"
}
"throws": "eval is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:5)"
}
"throws": "eval is a reserved word in strict mode (1:5)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:15)"
}
"throws": "eval is a reserved word in strict mode (1:15)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Binding eval in strict mode (1:1)"
}
"throws": "eval is a reserved word in strict mode (1:1)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:18)"
}
"throws": "eval is a reserved word in strict mode (1:18)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Assigning to eval in strict mode (1:16)"
}
"throws": "eval is a reserved word in strict mode (1:16)"
}

View File

@ -1,4 +1,4 @@
{
"sourceType": "module",
"throws": "Assigning to eval in strict mode (1:4)"
}
"throws": "eval is a reserved word in strict mode (1:4)"
}

View File

@ -0,0 +1 @@
await = foo();

View File

@ -0,0 +1,115 @@
{
"type": "File",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"program": {
"type": "Program",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 14
}
},
"expression": {
"type": "AssignmentExpression",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"operator": "=",
"left": {
"type": "Identifier",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "await"
},
"name": "await"
},
"right": {
"type": "CallExpression",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
}
},
"callee": {
"type": "Identifier",
"start": 8,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": []
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -0,0 +1 @@
await = foo();

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:0)"
}

View File

@ -0,0 +1 @@
const await = foo();

View File

@ -0,0 +1,117 @@
{
"type": "File",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"program": {
"type": "Program",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "await"
},
"name": "await"
},
"init": {
"type": "CallExpression",
"start": 14,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 19
}
},
"callee": {
"type": "Identifier",
"start": 14,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": []
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -0,0 +1 @@
const await = foo();

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:6)"
}

View File

@ -0,0 +1 @@
const { await } = foo();

View File

@ -0,0 +1,172 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"sourceType": "script",
"body": [
{
"type": "VariableDeclaration",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 6,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 23
}
},
"id": {
"type": "ObjectPattern",
"start": 6,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 15
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
},
"identifierName": "await"
},
"name": "await"
},
"value": {
"type": "Identifier",
"start": 8,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 1,
"column": 13
},
"identifierName": "await"
},
"name": "await"
},
"extra": {
"shorthand": true
}
}
]
},
"init": {
"type": "CallExpression",
"start": 18,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 23
}
},
"callee": {
"type": "Identifier",
"start": 18,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 21
},
"identifierName": "foo"
},
"name": "foo"
},
"arguments": []
}
}
],
"kind": "const"
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -0,0 +1 @@
const { await } = foo();

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:8)"
}

View File

@ -0,0 +1 @@
function foo({ await }) {}

View File

@ -0,0 +1,160 @@
{
"type": "File",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"program": {
"type": "Program",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 26
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "foo"
},
"name": "foo"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "ObjectPattern",
"start": 13,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 22
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "await"
},
"name": "await"
},
"value": {
"type": "Identifier",
"start": 15,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "await"
},
"name": "await"
},
"extra": {
"shorthand": true
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 24,
"end": 26,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 26
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
{
"sourceType": "script"
}

View File

@ -0,0 +1 @@
function foo({ await }) {}

View File

@ -0,0 +1,4 @@
{
"sourceType": "module",
"throws": "await is a reserved word (1:15)"
}

View File

@ -0,0 +1 @@
function await() {}

Some files were not shown because too many files have changed in this diff Show More