fix various bugs surfaced by the esprima test suite, remove some incorrect tests

This commit is contained in:
Sebastian McKenzie 2015-08-11 16:58:20 +01:00
parent 1a4f18aab7
commit a179f9a48b
45 changed files with 704 additions and 703 deletions

View File

@ -186,7 +186,7 @@ pp.parseMaybeUnary = function (refShorthandDefaultPos) {
if (refShorthandDefaultPos && refShorthandDefaultPos.start) this.unexpected(refShorthandDefaultPos.start);
if (update) {
this.checkLVal(node.argument);
} else if (this.strict && node.operator === "delete" && node.argument.type === "Identifier") {
} else if (this.state.strict && node.operator === "delete" && node.argument.type === "Identifier") {
this.raise(node.start, "Deleting local variable in strict mode");
}
return this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression");
@ -335,10 +335,8 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
return this.finishNode(node, "ThisExpression");
case tt._yield:
// NOTE: falls through to _let
if (!this.state.inGenerator && this.strict) this.unexpected();
if (this.state.inGenerator) this.unexpected();
case tt._let:
case tt.name:
node = this.startNode();
let id = this.parseIdentifier(true);
@ -363,7 +361,6 @@ pp.parseExprAtom = function (refShorthandDefaultPos) {
return id;
case tt._do:
if (this.options.features["es7.doExpressions"]) {
let node = this.startNode();
@ -683,7 +680,7 @@ pp.parseObjPropValue = function (prop, startPos, startLoc, isGenerator, isAsync,
prop.kind = "init";
if (isPattern) {
var illegalBinding = this.isKeyword(prop.key.name);
if (!illegalBinding && this.strict) {
if (!illegalBinding && this.state.strict) {
illegalBinding = reservedWords.strictBind(prop.key.name) || reservedWords.strict(prop.key.name);
}
if (illegalBinding) {
@ -772,19 +769,29 @@ pp.parseFunctionBody = function (node, allowExpression) {
// If this is a strict mode function, verify that argument names
// are not repeated, and it does not try to bind the words `eval`
// or `arguments`.
var checkLVal = this.strict;
var checkLVal = this.state.strict;
var checkLValStrict = false;
// arrow function
if (allowExpression) checkLVal = true;
// normal function
if (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) checkLVal = true;
if (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) {
checkLVal = true;
checkLValStrict = true;
}
if (checkLVal) {
let nameHash = Object.create(null);
let oldStrict = this.state.strict;
if (checkLValStrict) this.state.strict = true;
if (node.id) {
this.checkLVal(node.id, true);
}
for (let param of (node.params: Array)) {
this.checkLVal(param, true, nameHash);
}
this.state.strict = oldStrict;
}
};
@ -828,8 +835,8 @@ pp.parseExprListItem = function (allowEmpty, refShorthandDefaultPos) {
pp.parseIdentifier = function (liberal) {
let node = this.startNode();
if (this.isName()) {
if (!liberal && this.strict && reservedWords.strict(this.state.value)) {
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");
}
@ -847,7 +854,7 @@ pp.parseIdentifier = function (liberal) {
// Parses await expression inside async function.
pp.parseAwait = function (node) {
if (this.eat(tt.semi) || this.canInsertSemicolon()) {
if (this.isLineTerminator()) {
this.unexpected();
}
node.all = this.eat(tt.star);

View File

@ -1,4 +1,4 @@
import { reservedWords, isKeyword } from "../util/identifier";
import { reservedWords } from "../util/identifier";
import { getOptions } from "../options";
import Tokenizer from "../tokenizer";
@ -8,17 +8,16 @@ export const plugins = {};
export default class Parser extends Tokenizer {
constructor(options, input) {
super(input);
options = getOptions(options);
super(options, input);
this.options = getOptions(options);
this.isKeyword = isKeyword;
this.options = options;
this.isReservedWord = reservedWords[6];
this.input = input;
this.loadPlugins(this.options.plugins);
// Figure out if it's a module code.
this.inModule = this.options.sourceType === "module";
this.strict = this.options.strictMode === false ? false : this.inModule;
// If enabled, skip leading hashbang line.
if (this.state.pos === 0 && this.input[0] === "#" && this.input[1] === "!") {

View File

@ -92,7 +92,7 @@ pp.parseSpread = function (refShorthandDefaultPos) {
pp.parseRest = function () {
let node = this.startNode();
this.next();
if (this.isName() || this.match(tt.bracketL)) {
if (this.match(tt.name) || this.match(tt.bracketL)) {
node.argument = this.parseBindingAtom();
} else {
this.unexpected();
@ -103,7 +103,7 @@ pp.parseRest = function () {
// Parses lvalue (assignable) atom.
pp.parseBindingAtom = function () {
if (this.isName()) {
if (this.match(tt.name)) {
return this.parseIdentifier(true);
}
@ -168,7 +168,7 @@ pp.parseMaybeDefault = function (startPos, startLoc, left) {
pp.checkLVal = function (expr, isBinding, checkClashes) {
switch (expr.type) {
case "Identifier":
if (this.strict && (reservedWords.strictBind(expr.name) || reservedWords.strict(expr.name))) {
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");
}

View File

@ -74,19 +74,6 @@ pp.parseStatement = function (declaration, topLevel) {
case tt._try: return this.parseTryStatement(node);
case tt._let:
// NOTE: falls through to _const
if (!this.strict) {
let state = this.state.clone();
this.next();
var isBindingAtomStart = this.isName() || this.match(tt.braceL) || this.match(tt.bracketL);
// set back lookahead
this.state = state;
if (!isBindingAtomStart) break;
}
case tt._const:
if (!declaration) this.unexpected(); // NOTE: falls through to _var
@ -171,7 +158,7 @@ pp.parseBreakContinueStatement = function (node, keyword) {
let isBreak = keyword === "break";
this.next();
if (this.eat(tt.semi) || this.canInsertSemicolon()) {
if (this.isLineTerminator()) {
node.label = null;
} else if (!this.match(tt.name)) {
this.unexpected();
@ -232,9 +219,13 @@ pp.parseForStatement = function (node) {
this.next();
this.parseVar(init, true, varKind);
this.finishNode(init, "VariableDeclaration");
if ((this.match(tt._in) || this.isContextual("of")) && init.declarations.length === 1 &&
!(varKind !== tt._var && init.declarations[0].init))
return this.parseForIn(node, init);
if (this.match(tt._in) || this.isContextual("of")) {
if (init.declarations.length === 1 && !init.declarations[0].init) {
return this.parseForIn(node, init);
}
}
return this.parseFor(node, init);
}
@ -274,7 +265,7 @@ pp.parseReturnStatement = function (node) {
// optional arguments, we eagerly look for a semicolon or the
// possibility to insert one.
if (this.eat(tt.semi) || this.canInsertSemicolon()) {
if (this.isLineTerminator()) {
node.argument = null;
} else {
node.argument = this.parseExpression();
@ -343,7 +334,7 @@ pp.parseTryStatement = function (node) {
this.next();
this.expect(tt.parenL);
clause.param = this.parseBindingAtom();
this.checkLVal(clause.param, true);
this.checkLVal(clause.param, true, Object.create(null));
this.expect(tt.parenR);
clause.body = this.parseBlock();
node.handler = this.finishNode(clause, "CatchClause");
@ -376,7 +367,7 @@ pp.parseWhileStatement = function (node) {
};
pp.parseWithStatement = function (node) {
if (this.strict) this.raise(this.state.start, "'with' in strict mode");
if (this.state.strict) this.raise(this.state.start, "'with' in strict mode");
this.next();
node.object = this.parseParenExpression();
node.body = this.parseStatement(false);
@ -431,8 +422,8 @@ pp.parseBlock = function (allowStrict) {
let stmt = this.parseStatement(true);
node.body.push(stmt);
if (first && allowStrict && this.isUseStrict(stmt)) {
oldStrict = this.strict;
this.setStrict(this.strict = true);
oldStrict = this.state.strict;
this.setStrict(this.state.strict = true);
}
first = false;
}
@ -505,11 +496,11 @@ pp.parseFunction = function (node, isStatement, allowExpressionBody, isAsync, op
this.initFunction(node, isAsync);
node.generator = this.eat(tt.star);
if (isStatement && !optionalId && !this.isName()) {
if (isStatement && !optionalId && !this.match(tt.name)) {
this.unexpected();
}
if (this.isName()) {
if (this.match(tt.name)) {
node.id = this.parseIdentifier();
}

View File

@ -28,23 +28,6 @@ pp.expectRelational = function (op) {
}
};
// TODO
pp.isName = function () {
if (this.match(tt.name)) {
return true;
} else if (!this.strict) {
var keyword = this.state.type.keyword;
if (keyword === "let") {
return true;
} else if (keyword === "yield") {
return !this.state.inGenerator;
}
}
return false;
};
// Tests whether parsed token is a contextual keyword.
pp.isContextual = function (name) {
@ -71,6 +54,12 @@ pp.canInsertSemicolon = function () {
lineBreak.test(this.input.slice(this.state.lastTokEnd, this.state.start));
};
// TODO
pp.isLineTerminator = function () {
return this.eat(tt.semi) || this.canInsertSemicolon();
};
// Consume a semicolon, or, failing that, see if we are allowed to
// pretend that there is a semicolon at this position.

View File

@ -609,7 +609,7 @@ export default function (instance) {
instance.extend("parseStatement", function (inner) {
return function (declaration, topLevel) {
// strict mode handling of `interface` since it's a reserved word
if (this.strict && this.match(tt.name) && this.state.value === "interface") {
if (this.state.strict && this.match(tt.name) && this.state.value === "interface") {
var node = this.startNode();
this.next();
return this.flowParseInterface(node);

View File

@ -1,4 +1,4 @@
import { isIdentifierStart, isIdentifierChar } from "../util/identifier";
import { isIdentifierStart, isIdentifierChar, isKeyword } from "../util/identifier";
import { types as tt, keywords as keywordTypes } from "./types";
import { types as ct } from "./context";
import { SourceLocation } from "../util/location";
@ -48,9 +48,9 @@ function codePointToString(code) {
}
export default class Tokenizer {
constructor(input) {
constructor(options, input) {
this.state = new State;
this.state.init(input);
this.state.init(options, input);
}
// Move to the next token
@ -84,6 +84,22 @@ export default class Tokenizer {
// TODO
isKeyword(word) {
if (!this.state.strict) {
if (word === "yield" && !this.state.inGenerator) {
return false;
}
if (word === "let") {
// check if next token is a name, braceL or bracketL, if so, it's a keyword!
}
}
return isKeyword(word);
}
// TODO
lookahead() {
var old = this.state;
this.state = old.clone();
@ -97,7 +113,7 @@ export default class Tokenizer {
// pedantic tests (`"use strict"; 010;` should fail).
setStrict(strict) {
this.strict = strict;
this.state.strict = strict;
if (!this.match(tt.num) && !this.match(tt.string)) return;
this.state.pos = this.state.start;
while (this.state.pos < this.state.lineStart) {
@ -589,7 +605,7 @@ export default class Tokenizer {
val = parseFloat(str);
} else if (!octal || str.length === 1) {
val = parseInt(str, 10);
} else if (/[89]/.test(str) || this.strict) {
} else if (/[89]/.test(str) || this.state.strict) {
this.raise(start, "Invalid number");
} else {
val = parseInt(str, 8);
@ -705,7 +721,7 @@ export default class Tokenizer {
octalStr = octalStr.slice(0, -1);
octal = parseInt(octalStr, 8);
}
if (octal > 0 && (this.strict || inTemplate)) {
if (octal > 0 && (this.state.strict || inTemplate)) {
this.raise(this.state.pos - 2, "Octal literal in strict mode");
}
this.state.pos += octalStr.length - 1;
@ -769,8 +785,9 @@ export default class Tokenizer {
readWord() {
let word = this.readWord1();
let type = tt.name;
if (!this.state.containsEsc && this.isKeyword(word))
if (!this.state.containsEsc && this.isKeyword(word)) {
type = keywordTypes[word];
}
return this.finishToken(type, word);
}

View File

@ -3,7 +3,10 @@ import { types as ct } from "./context";
import { types as tt } from "./types";
export default class State {
init(input) {
init(options, input) {
// strict
this.strict = options.strictMode === false ? false : options.sourceType === "module";
this.input = input;
// Used to signify the start of a potential arrow function

View File

@ -1 +0,0 @@
for (var x = 42 in list) process(x);

View File

@ -1,195 +0,0 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"body": [
{
"type": "ForInStatement",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"left": {
"type": "VariableDeclaration",
"start": 5,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 15
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 9,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 15
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "x"
},
"init": {
"type": "Literal",
"start": 13,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 15
}
},
"value": 42,
"rawValue": 42,
"raw": "42"
}
}
],
"kind": "var"
},
"right": {
"type": "Identifier",
"start": 19,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 23
}
},
"name": "list"
},
"body": {
"type": "ExpressionStatement",
"start": 25,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 36
}
},
"expression": {
"type": "CallExpression",
"start": 25,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 35
}
},
"callee": {
"type": "Identifier",
"start": 25,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 25
},
"end": {
"line": 1,
"column": 32
}
},
"name": "process"
},
"arguments": [
{
"type": "Identifier",
"start": 33,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 34
}
},
"name": "x"
}
]
}
}
}
]
}
}

View File

@ -1 +0,0 @@
for (var i = function() { return 10 in [] } in list) process(x);

View File

@ -1,278 +0,0 @@
{
"type": "File",
"start": 0,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 64
}
},
"program": {
"type": "Program",
"start": 0,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 64
}
},
"sourceType": "script",
"body": [
{
"type": "ForInStatement",
"start": 0,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 64
}
},
"left": {
"type": "VariableDeclaration",
"start": 5,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 43
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 9,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 43
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 10
}
},
"name": "i"
},
"init": {
"type": "FunctionExpression",
"start": 13,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 43
}
},
"id": null,
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 24,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 43
}
},
"body": [
{
"type": "ReturnStatement",
"start": 26,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 26
},
"end": {
"line": 1,
"column": 41
}
},
"argument": {
"type": "BinaryExpression",
"start": 33,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 41
}
},
"left": {
"type": "Literal",
"start": 33,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 33
},
"end": {
"line": 1,
"column": 35
}
},
"value": 10,
"rawValue": 10,
"raw": "10"
},
"operator": "in",
"right": {
"type": "ArrayExpression",
"start": 39,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 39
},
"end": {
"line": 1,
"column": 41
}
},
"elements": []
}
}
}
]
}
}
}
],
"kind": "var"
},
"right": {
"type": "Identifier",
"start": 47,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 47
},
"end": {
"line": 1,
"column": 51
}
},
"name": "list"
},
"body": {
"type": "ExpressionStatement",
"start": 53,
"end": 64,
"loc": {
"start": {
"line": 1,
"column": 53
},
"end": {
"line": 1,
"column": 64
}
},
"expression": {
"type": "CallExpression",
"start": 53,
"end": 63,
"loc": {
"start": {
"line": 1,
"column": 53
},
"end": {
"line": 1,
"column": 63
}
},
"callee": {
"type": "Identifier",
"start": 53,
"end": 60,
"loc": {
"start": {
"line": 1,
"column": 53
},
"end": {
"line": 1,
"column": 60
}
},
"name": "process"
},
"arguments": [
{
"type": "Identifier",
"start": 61,
"end": 62,
"loc": {
"start": {
"line": 1,
"column": 61
},
"end": {
"line": 1,
"column": 62
}
},
"name": "x"
}
]
}
}
}
]
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,3 @@
{
"throws": "Argument name clash in strict mode (1:14)"
}

View File

@ -0,0 +1,3 @@
{
"throws": "Argument name clash in strict mode (2:14)"
}

View File

@ -0,0 +1,3 @@
{
"throws": "Argument name clash in strict mode (2:17)"
}

View File

@ -0,0 +1,3 @@
{
"throws": "Argument name clash in strict mode (2:19)"
}

View File

@ -1,3 +1,3 @@
{
"throws": "Unexpected token (1:20)"
}
"throws": "Argument name clash in strict mode (1:17)"
}

View File

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

View File

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

View File

@ -0,0 +1,153 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"expression": {
"type": "FunctionExpression",
"start": 1,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 22
}
},
"id": null,
"generator": true,
"expression": false,
"params": [
{
"type": "ObjectPattern",
"start": 11,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 18
}
},
"properties": [
{
"type": "Property",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 17
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 17
}
},
"name": "yield"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 17
}
},
"name": "yield"
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 22
}
},
"body": []
},
"parenthesizedExpression": true
}
}
]
}
}

View File

@ -1,3 +1,3 @@
{
"throws": "Unexpected super (3:9)"
"throws": "Unexpected super (3:14)"
}

View File

@ -0,0 +1,148 @@
{
"type": "File",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"program": {
"type": "Program",
"start": 0,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 36
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"expression": {
"type": "Literal",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"value": "use strict",
"rawValue": "use strict",
"raw": "\"use strict\""
}
},
{
"type": "FunctionDeclaration",
"start": 14,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 36
}
},
"id": {
"type": "Identifier",
"start": 23,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 23
},
"end": {
"line": 1,
"column": 24
}
},
"name": "f"
},
"generator": false,
"expression": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 27,
"end": 36,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 36
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 34
}
},
"expression": {
"type": "Identifier",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 1,
"column": 29
},
"end": {
"line": 1,
"column": 34
}
},
"name": "yield"
}
}
]
}
}
]
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,128 @@
{
"type": "File",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"program": {
"type": "Program",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"sourceType": "module",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"expression": {
"type": "AssignmentExpression",
"start": 0,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 15
}
},
"operator": "=",
"left": {
"type": "ArrayPattern",
"start": 0,
"end": 9,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 9
}
},
"elements": [
{
"type": "RestElement",
"start": 1,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 8
}
},
"argument": {
"type": "Identifier",
"start": 4,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 8
}
},
"name": "eval"
}
}
]
},
"right": {
"type": "Identifier",
"start": 12,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 15
}
},
"name": "arr"
}
}
}
]
}
}

View File

@ -0,0 +1,152 @@
{
"type": "File",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"program": {
"type": "Program",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 23
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
}
},
"name": "y"
},
"generator": true,
"expression": false,
"params": [
{
"type": "ObjectPattern",
"start": 12,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 19
}
},
"properties": [
{
"type": "Property",
"start": 13,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 18
}
},
"method": false,
"shorthand": true,
"computed": false,
"key": {
"type": "Identifier",
"start": 13,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 18
}
},
"name": "yield"
},
"kind": "init",
"value": {
"type": "Identifier",
"start": 13,
"end": 18,
"loc": {
"start": {
"line": 1,
"column": 13
},
"end": {
"line": 1,
"column": 18
}
},
"name": "yield"
}
}
]
}
],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 21
},
"end": {
"line": 1,
"column": 23
}
},
"body": []
}
}
]
}
}

View File

@ -1 +0,0 @@
(a, a) => 42

View File

@ -1,119 +0,0 @@
{
"type": "File",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"program": {
"type": "Program",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 12
}
},
"id": null,
"generator": false,
"expression": true,
"params": [
{
"type": "Identifier",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
}
},
"name": "a"
},
{
"type": "Identifier",
"start": 4,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 4
},
"end": {
"line": 1,
"column": 5
}
},
"name": "a"
}
],
"body": {
"type": "Literal",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
}
},
"value": 42,
"rawValue": 42,
"raw": "42"
}
}
}
]
},
"comments": []
}