"yield" parsing inside function name and parameters (#689)

* Use parseFunctionParams to parse method parameters

* [funct] Set this.state.inGenerator before parsing the function name/params

This allows "yield" inside generator parameters to be actually
parsed as a yield expression

* [funct] Disallow yield in function parameters

* [arrow] "yield" can start an arrow function (e.g. "yield => {}")

* [arrow] Disallow YieldExpressions inside arrow parameters.

* [err msg] Disallow yield as fn name in strict mode using checkReservedWord.

So Babylon throws "yield is a reserved word" instead of
a custom "Binding yield in strict mode"

* [err msg] "X is reserved in strict mode" should have precedence over "X is reserved", since it is more specific.

This was observable if "checkKeywords" is true and the word is both a keyword and a reserved
word in strict mode

* Disallow "yield" as an identifier inside generators

* [tests] Add tests, update wrong esprima tests and enable disabled esprima tests

* [tests] Move uncategorized tests to es2015/yield

* [tests] Update test262 whitelist

* Fix regression introduced by 8c77073

* [tests] Update flow whitelist

* Fix flow errors
This commit is contained in:
Daniel Tschinder 2017-11-01 16:04:22 +01:00 committed by Daniel Tschinder
parent 29a4aea27b
commit 1b612148bf
171 changed files with 3067 additions and 163 deletions

View File

@ -10,7 +10,6 @@
ES6/binding-pattern/object-pattern/await-prop-in-async-function.js
JSX_invalid/migrated_0000.js
arrow_function/param-dflt-yield-expr.js
arrow_function_invalid/migrated_0002.js
async_await/async_generic_method.js
async_await/migrated_0020.js

View File

@ -109,8 +109,6 @@ language/export/escaped-as-export-specifier.js(default)
language/export/escaped-as-export-specifier.js(strict mode)
language/export/escaped-from.js(default)
language/export/escaped-from.js(strict mode)
language/expressions/arrow-function/param-dflt-yield-expr.js(default)
language/expressions/arrow-function/param-dflt-yield-expr.js(strict mode)
language/expressions/assignment/dstr-array-rest-before-elision.js(default)
language/expressions/assignment/dstr-array-rest-before-elision.js(strict mode)
language/expressions/assignment/dstr-array-rest-elision-invalid.js(default)
@ -130,11 +128,7 @@ language/expressions/async-function/escaped-async.js(strict mode)
language/expressions/async-function/named-dflt-params-duplicates.js(default)
language/expressions/async-function/nameless-dflt-params-duplicates.js(default)
language/expressions/function/dflt-params-duplicates.js(default)
language/expressions/function/param-dflt-yield-strict.js(strict mode)
language/expressions/generators/dflt-params-duplicates.js(default)
language/expressions/generators/param-dflt-yield.js(default)
language/expressions/generators/yield-as-generator-expression-binding-identifier.js(default)
language/expressions/generators/yield-as-parameter.js(default)
language/expressions/new.target/escaped-target.js(default)
language/expressions/new.target/escaped-target.js(strict mode)
language/expressions/object/method-definition/async-meth-escaped-async.js(default)
@ -151,8 +145,6 @@ language/expressions/object/method-definition/escaped-get.js(strict mode)
language/expressions/object/method-definition/escaped-set.js(default)
language/expressions/object/method-definition/escaped-set.js(strict mode)
language/expressions/object/method-definition/gen-meth-dflt-params-duplicates.js(default)
language/expressions/object/method-definition/generator-param-id-yield.js(default)
language/expressions/object/method-definition/generator-param-init-yield.js(default)
language/expressions/object/method-definition/generator-param-redecl-const.js(default)
language/expressions/object/method-definition/generator-param-redecl-const.js(strict mode)
language/expressions/object/method-definition/generator-param-redecl-let.js(default)
@ -160,7 +152,6 @@ language/expressions/object/method-definition/generator-param-redecl-let.js(stri
language/expressions/object/method-definition/meth-dflt-params-duplicates.js(default)
language/expressions/object/method-definition/name-param-redecl.js(default)
language/expressions/object/method-definition/name-param-redecl.js(strict mode)
language/expressions/object/method-definition/yield-as-parameter.js(default)
language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(default)
language/expressions/template-literal/invalid-legacy-octal-escape-sequence.js(strict mode)
language/expressions/yield/in-iteration-stmt.js(default)
@ -318,10 +309,7 @@ language/statements/for-of/labelled-fn-stmt-let.js(default)
language/statements/for-of/labelled-fn-stmt-lhs.js(default)
language/statements/for-of/labelled-fn-stmt-var.js(default)
language/statements/function/dflt-params-duplicates.js(default)
language/statements/function/param-dflt-yield-strict.js(strict mode)
language/statements/generators/dflt-params-duplicates.js(default)
language/statements/generators/param-dflt-yield.js(default)
language/statements/generators/yield-as-parameter.js(default)
language/statements/if/if-async-fun-else-async-fun.js(default)
language/statements/if/if-async-fun-else-async-fun.js(strict mode)
language/statements/if/if-async-fun-else-stmt.js(default)
@ -634,7 +622,6 @@ language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-id.js(default)
language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-id.js(strict mode)
language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js(default)
language/expressions/arrow-function/dstr-dflt-ary-ptrn-rest-obj-prop-id.js(strict mode)
language/expressions/arrow-function/syntax/arrowparameters-bindingidentifier-yield.js(default)
language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(default)
language/expressions/assignment/destructuring/obj-prop-__proto__dup.js(strict mode)
language/expressions/assignment/dstr-array-rest-nested-obj-null.js(default)
@ -652,10 +639,8 @@ language/expressions/assignment/dstr-array-rest-nested-obj.js(default)
language/expressions/assignment/dstr-array-rest-nested-obj.js(strict mode)
language/expressions/assignment/dstr-obj-id-identifier-yield-ident-valid.js(default)
language/expressions/generators/yield-as-function-expression-binding-identifier.js(default)
language/expressions/object/let-non-strict-access.js(default)
language/expressions/object/let-non-strict-syntax.js(default)
language/expressions/object/method-definition/yield-as-function-expression-binding-identifier.js(default)
language/expressions/object/yield-non-strict-access.js(default)
language/expressions/object/yield-non-strict-syntax.js(default)
language/statements/for/head-lhs-let.js(default)
@ -707,7 +692,6 @@ language/statements/for-of/dstr-obj-id-identifier-yield-ident-valid.js(default)
language/statements/for-of/head-var-bound-names-let.js(default)
language/statements/for-of/let-block-with-newline.js(default)
language/statements/for-of/let-identifier-with-newline.js(default)
language/statements/generators/yield-as-function-expression-binding-identifier.js(default)
language/statements/if/let-block-with-newline.js(default)
language/statements/if/let-identifier-with-newline.js(default)
language/statements/labeled/let-block-with-newline.js(default)
@ -757,9 +741,6 @@ language/expressions/async-generator/early-errors-expression-formals-body-duplic
language/expressions/async-generator/early-errors-expression-formals-body-duplicate-let.js(strict mode)
language/expressions/async-generator/early-errors-expression-formals-contains-await.js(default)
language/expressions/async-generator/early-errors-expression-formals-contains-await.js(strict mode)
language/expressions/async-generator/early-errors-expression-formals-contains-yield-expr.js(default)
language/expressions/async-generator/early-errors-expression-formals-contains-yield.js(default)
language/expressions/async-generator/early-errors-expression-yield-as-function-binding-identifier.js(default)
language/expressions/async-generator/escaped-async.js(default)
language/expressions/async-generator/escaped-async.js(strict mode)
language/expressions/async-generator/named-dflt-params-duplicates.js(default)

View File

@ -42,6 +42,7 @@ export default class ExpressionParser extends LValParser {
isAsync?: boolean,
optionalId?: boolean,
) => T;
+parseFunctionParams: (node: N.Function, allowModifiers?: boolean) => void;
+takeDecorators: (node: N.HasDecorators) => void;
// Check if property name clashes with already added.
@ -136,7 +137,7 @@ export default class ExpressionParser extends LValParser {
failOnShorthandAssign = true;
}
if (this.match(tt.parenL) || this.match(tt.name)) {
if (this.match(tt.parenL) || this.match(tt.name) || this.match(tt._yield)) {
this.state.potentialArrowAt = this.state.start;
}
@ -929,6 +930,11 @@ export default class ExpressionParser extends LValParser {
let val;
this.expect(tt.parenL);
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
const oldYield = this.state.yieldInPossibleArrowParameters;
this.state.maybeInArrowParameters = true;
this.state.yieldInPossibleArrowParameters = null;
const innerStartPos = this.state.start;
const innerStartLoc = this.state.startLoc;
const exprList = [];
@ -985,6 +991,8 @@ export default class ExpressionParser extends LValParser {
const innerEndLoc = this.state.startLoc;
this.expect(tt.parenR);
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
let arrowNode = this.startNodeAt(startPos, startLoc);
if (
canBeArrow &&
@ -996,9 +1004,13 @@ export default class ExpressionParser extends LValParser {
this.unexpected(param.extra.parenStart);
}
return this.parseArrowExpression(arrowNode, exprList);
this.parseArrowExpression(arrowNode, exprList);
this.state.yieldInPossibleArrowParameters = oldYield;
return arrowNode;
}
this.state.yieldInPossibleArrowParameters = oldYield;
if (!exprList.length) {
this.unexpected(this.state.lastTokStart);
}
@ -1463,20 +1475,21 @@ export default class ExpressionParser extends LValParser {
): T {
const oldInFunc = this.state.inFunction;
const oldInMethod = this.state.inMethod;
const oldInGenerator = this.state.inGenerator;
this.state.inFunction = true;
this.state.inMethod = node.kind || true;
this.state.inGenerator = isGenerator;
this.initFunction(node, isAsync);
this.expect(tt.parenL);
const allowModifiers = isConstructor; // For TypeScript parameter properties
node.params = this.parseBindingList(
tt.parenR,
/* allowEmpty */ false,
allowModifiers,
);
node.generator = !!isGenerator;
const allowModifiers = isConstructor; // For TypeScript parameter properties
this.parseFunctionParams((node: any), allowModifiers);
this.parseFunctionBodyAndFinish(node, type);
this.state.inFunction = oldInFunc;
this.state.inMethod = oldInMethod;
this.state.inGenerator = oldInGenerator;
return node;
}
@ -1487,12 +1500,30 @@ export default class ExpressionParser extends LValParser {
params: N.Expression[],
isAsync?: boolean,
): N.ArrowFunctionExpression {
// if we got there, it's no more "yield in possible arrow parameters";
// it's just "yield in arrow parameters"
if (this.state.yieldInPossibleArrowParameters) {
this.raise(
this.state.yieldInPossibleArrowParameters.start,
"yield is not allowed in the parameters of an arrow function" +
" inside a generator",
);
}
const oldInFunc = this.state.inFunction;
this.state.inFunction = true;
this.initFunction(node, isAsync);
this.setArrowFunctionParameters(node, params);
const oldInGenerator = this.state.inGenerator;
const oldMaybeInArrowParameters = this.state.maybeInArrowParameters;
this.state.inGenerator = false;
this.state.maybeInArrowParameters = false;
this.parseFunctionBody(node, true);
this.state.inGenerator = oldInGenerator;
this.state.inFunction = oldInFunc;
this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
return this.finishNode(node, "ArrowFunctionExpression");
}
@ -1536,8 +1567,11 @@ export default class ExpressionParser extends LValParser {
parseFunctionBody(node: N.Function, allowExpression: ?boolean): void {
const isExpression = allowExpression && !this.match(tt.braceL);
const oldInParameters = this.state.inParameters;
const oldInAsync = this.state.inAsync;
this.state.inParameters = false;
this.state.inAsync = node.async;
if (isExpression) {
node.body = this.parseMaybeAssign();
node.expression = true;
@ -1545,17 +1579,21 @@ export default class ExpressionParser extends LValParser {
// Start a new scope with regard to labels and the `inGenerator`
// flag (restore them to their old value afterwards).
const oldInGen = this.state.inGenerator;
const oldInFunc = this.state.inFunction;
const oldLabels = this.state.labels;
this.state.inGenerator = node.generator;
this.state.inFunction = true;
this.state.labels = [];
node.body = this.parseBlock(true);
node.expression = false;
this.state.inFunction = oldInFunc;
this.state.inGenerator = oldInGen;
this.state.labels = oldLabels;
}
this.state.inAsync = oldInAsync;
this.checkFunctionNameAndParams(node, allowExpression);
this.state.inParameters = oldInParameters;
}
checkFunctionNameAndParams(
@ -1569,19 +1607,13 @@ export default class ExpressionParser extends LValParser {
// Also check for arrow functions
const checkLVal = this.state.strict || isStrict || isArrowFunction;
if (
isStrict &&
node.id &&
node.id.type === "Identifier" &&
node.id.name === "yield"
) {
this.raise(node.id.start, "Binding yield in strict mode");
const oldStrict = this.state.strict;
if (isStrict) this.state.strict = isStrict;
if (node.id) {
this.checkReservedWord(node.id, node.start, true, true);
}
if (checkLVal) {
const nameHash: any = Object.create(null);
const oldStrict = this.state.strict;
if (isStrict) this.state.strict = true;
if (node.id) {
this.checkLVal(node.id, true, undefined, "function name");
}
@ -1591,8 +1623,8 @@ export default class ExpressionParser extends LValParser {
}
this.checkLVal(param, true, nameHash, "function parameter list");
}
this.state.strict = oldStrict;
}
this.state.strict = oldStrict;
}
// Parses a comma-separated list of expressions, and returns them as
@ -1694,10 +1726,6 @@ export default class ExpressionParser extends LValParser {
checkKeywords: boolean,
isBinding: boolean,
): void {
if (this.isReservedWord(word) || (checkKeywords && this.isKeyword(word))) {
this.raise(startLoc, word + " is a reserved word");
}
if (
this.state.strict &&
(reservedWords.strict(word) ||
@ -1705,6 +1733,17 @@ export default class ExpressionParser extends LValParser {
) {
this.raise(startLoc, word + " is a reserved word in strict mode");
}
if (this.state.inGenerator && word === "yield") {
this.raise(
startLoc,
"yield is a reserved word inside generator functions",
);
}
if (this.isReservedWord(word) || (checkKeywords && this.isKeyword(word))) {
this.raise(startLoc, word + " is a reserved word");
}
}
// Parses await expression inside async function.
@ -1728,6 +1767,19 @@ export default class ExpressionParser extends LValParser {
parseYield(): N.YieldExpression {
const node = this.startNode();
if (this.state.inParameters) {
this.raise(node.start, "yield is not allowed in generator parameters");
}
if (
this.state.maybeInArrowParameters &&
// We only set yieldInPossibleArrowParameters if we haven't already
// found a possible invalid YieldExpression.
!this.state.yieldInPossibleArrowParameters
) {
this.state.yieldInPossibleArrowParameters = node;
}
this.next();
if (
this.match(tt.semi) ||

View File

@ -780,6 +780,7 @@ export default class StatementParser extends ExpressionParser {
): T {
const oldInFunc = this.state.inFunction;
const oldInMethod = this.state.inMethod;
const oldInGenerator = this.state.inGenerator;
this.state.inFunction = true;
this.state.inMethod = false;
@ -802,9 +803,19 @@ export default class StatementParser extends ExpressionParser {
this.unexpected();
}
// When parsing function expression, the binding identifier is parsed
// according to the rules inside the function.
// e.g. (function* yield() {}) is invalid because "yield" is disallowed in
// generators.
// This isn't the case with function declarations: function* yield() {} is
// valid because yield is parsed as if it was outside the generator.
// Therefore, this.state.inGenerator is set before or after parsing the
// function id according to the "isStatement" parameter.
if (!isStatement) this.state.inGenerator = node.generator;
if (this.match(tt.name) || this.match(tt._yield)) {
node.id = this.parseBindingIdentifier();
}
if (isStatement) this.state.inGenerator = node.generator;
this.parseFunctionParams(node);
this.parseFunctionBodyAndFinish(
@ -812,14 +823,26 @@ export default class StatementParser extends ExpressionParser {
isStatement ? "FunctionDeclaration" : "FunctionExpression",
allowExpressionBody,
);
this.state.inFunction = oldInFunc;
this.state.inMethod = oldInMethod;
this.state.inGenerator = oldInGenerator;
return node;
}
parseFunctionParams(node: N.Function): void {
parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {
const oldInParameters = this.state.inParameters;
this.state.inParameters = true;
this.expect(tt.parenL);
node.params = this.parseBindingList(tt.parenR);
node.params = this.parseBindingList(
tt.parenR,
/* allowEmpty */ false,
allowModifiers,
);
this.state.inParameters = oldInParameters;
}
// Parse a class declaration or literal (depending on the

View File

@ -2002,7 +2002,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
// parse function type parameters - function foo<T>() {}
parseFunctionParams(node: N.Function): void {
if (this.isRelational("<")) {
// $FlowFixMe
const kind = node.kind;
if (kind !== "get" && kind !== "set" && this.isRelational("<")) {
node.typeParameters = this.flowParseTypeParameterDeclaration();
}
super.parseFunctionParams(node);

View File

@ -1679,10 +1679,10 @@ export default (superClass: Class<Parser>): Class<Parser> =>
super.parseObjPropValue(prop, ...args);
}
parseFunctionParams(node: N.Function): void {
parseFunctionParams(node: N.Function, allowModifiers?: boolean): void {
const typeParameters = this.tsTryParseTypeParameters();
if (typeParameters) node.typeParameters = typeParameters;
super.parseFunctionParams(node);
super.parseFunctionParams(node, allowModifiers);
}
// `let x: number;`

View File

@ -21,7 +21,7 @@ export default class State {
this.noArrowParamsConversionAt = [];
// eslint-disable-next-line max-len
this.inMethod = this.inFunction = this.inGenerator = this.inAsync = this.inPropertyName = this.inType = this.inClassProperty = this.noAnonFunctionType = false;
this.inMethod = this.inFunction = this.inParameters = this.maybeInArrowParameters = this.inGenerator = this.inAsync = this.inPropertyName = this.inType = this.inClassProperty = this.noAnonFunctionType = false;
this.classLevel = 0;
@ -29,6 +29,8 @@ export default class State {
this.decoratorStack = [[]];
this.yieldInPossibleArrowParameters = null;
this.tokens = [];
this.comments = [];
@ -87,6 +89,8 @@ export default class State {
// Flags to track whether we are in a function, a generator.
inFunction: boolean;
inParameters: boolean;
maybeInArrowParameters: boolean;
inGenerator: boolean;
inMethod: boolean | N.MethodKind;
inAsync: boolean;
@ -106,6 +110,11 @@ export default class State {
// where @foo belongs to the outer class and @bar to the inner
decoratorStack: Array<Array<N.Decorator>>;
// The first yield expression inside parenthesized expressions and arrow
// function parameters. It is used to disallow yield in arrow function
// parameters.
yieldInPossibleArrowParameters: ?N.YieldExpression;
// Token store.
tokens: Array<Token | N.Comment>;

View File

@ -1 +0,0 @@
yield v

View File

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

View File

@ -0,0 +1,3 @@
function* fn() {
function yield() {}
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (2:11)"
}

View File

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

View File

@ -0,0 +1,87 @@
{
"type": "File",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"program": {
"type": "Program",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 19
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 14,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 14
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 17,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 17
},
"end": {
"line": 1,
"column": 19
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
function* fn() {
(function yield() {});
}

View File

@ -0,0 +1,160 @@
{
"type": "File",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 43,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 24
}
},
"expression": {
"type": "FunctionExpression",
"start": 20,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 22
}
},
"id": {
"type": "Identifier",
"start": 29,
"end": 34,
"loc": {
"start": {
"line": 2,
"column": 12
},
"end": {
"line": 2,
"column": 17
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 37,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 22
}
},
"body": [],
"directives": []
},
"extra": {
"parenthesized": true,
"parenStart": 19
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

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

View File

@ -0,0 +1,122 @@
{
"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": "ExpressionStatement",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"expression": {
"type": "UnaryExpression",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"operator": "+",
"prefix": true,
"argument": {
"type": "FunctionExpression",
"start": 1,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 20
}
},
"body": [],
"directives": []
}
},
"extra": {
"parenthesizedArgument": false
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
class A {
yield() {}
}

View File

@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 12
}
},
"static": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "yield"
},
"name": "yield"
},
"kind": "method",
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 20,
"end": 22,
"loc": {
"start": {
"line": 2,
"column": 10
},
"end": {
"line": 2,
"column": 12
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
function* yield() {}

View File

@ -0,0 +1,87 @@
{
"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": "FunctionDeclaration",
"start": 0,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 20
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 18,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 20
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
+function* yield() {}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:11)"
}

View File

@ -0,0 +1,3 @@
class A {
*yield() {}
}

View File

@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "ClassDeclaration",
"start": 0,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 6,
"end": 7,
"loc": {
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 7
},
"identifierName": "A"
},
"name": "A"
},
"superClass": null,
"body": {
"type": "ClassBody",
"start": 8,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 8
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ClassMethod",
"start": 12,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"static": false,
"kind": "method",
"computed": false,
"key": {
"type": "Identifier",
"start": 13,
"end": 18,
"loc": {
"start": {
"line": 2,
"column": 3
},
"end": {
"line": 2,
"column": 8
},
"identifierName": "yield"
},
"name": "yield"
},
"id": null,
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 21,
"end": 23,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 13
}
},
"body": [],
"directives": []
}
}
]
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
function fn() {
function yield() {}
}

View File

@ -0,0 +1,141 @@
{
"type": "File",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 14,
"end": 39,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "FunctionDeclaration",
"start": 18,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 21
}
},
"id": {
"type": "Identifier",
"start": 27,
"end": 32,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "yield"
},
"name": "yield"
},
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 35,
"end": 37,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 21
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
function yield() { "use strict"; }

View File

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

View File

@ -0,0 +1,2 @@
"use strict";
function yield() {}

View File

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

View File

@ -0,0 +1,4 @@
function* fn() {
() => yield;
() => { yield };
}

View File

@ -0,0 +1,225 @@
{
"type": "File",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 4,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 52,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 4,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 14
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 13
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "Identifier",
"start": 25,
"end": 30,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 13
},
"identifierName": "yield"
},
"name": "yield"
}
}
},
{
"type": "ExpressionStatement",
"start": 34,
"end": 50,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 18
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 34,
"end": 49,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 17
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 40,
"end": 49,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 17
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 42,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 15
}
},
"expression": {
"type": "Identifier",
"start": 42,
"end": 47,
"loc": {
"start": {
"line": 3,
"column": 10
},
"end": {
"line": 3,
"column": 15
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"directives": []
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
function* fn() {
() => (x = yield) => {};
}

View File

@ -0,0 +1,210 @@
{
"type": "File",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 45,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 43,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 26
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 25
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "ArrowFunctionExpression",
"start": 25,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 25
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 26,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 18
}
},
"left": {
"type": "Identifier",
"start": 26,
"end": 27,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "Identifier",
"start": 30,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 13
},
"end": {
"line": 2,
"column": 18
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"body": {
"type": "BlockStatement",
"start": 40,
"end": 42,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 25
}
},
"body": [],
"directives": []
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
function* fn() {
(x = yield) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:7)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
(x = 3 + a.b(yield) ** 2) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:15)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
(x = yield fn) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:7)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
(a, b = 3, x = yield) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:17)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
(x = (yield) => {}) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:8)"
}

View File

@ -0,0 +1 @@
(x = yield) => {}

View File

@ -0,0 +1,136 @@
{
"type": "File",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"program": {
"type": "Program",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 17
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 1,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 10
}
},
"left": {
"type": "Identifier",
"start": 1,
"end": 2,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 2
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "Identifier",
"start": 5,
"end": 10,
"loc": {
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 10
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 1,
"column": 17
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
function* fn() {
function fn2(x = yield) {}
}

View File

@ -0,0 +1,191 @@
{
"type": "File",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 47,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "FunctionDeclaration",
"start": 19,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 28
}
},
"id": {
"type": "Identifier",
"start": 28,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 14
},
"identifierName": "fn2"
},
"name": "fn2"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "AssignmentPattern",
"start": 32,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 24
}
},
"left": {
"type": "Identifier",
"start": 32,
"end": 33,
"loc": {
"start": {
"line": 2,
"column": 15
},
"end": {
"line": 2,
"column": 16
},
"identifierName": "x"
},
"name": "x"
},
"right": {
"type": "Identifier",
"start": 36,
"end": 41,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 24
},
"identifierName": "yield"
},
"name": "yield"
}
}
],
"body": {
"type": "BlockStatement",
"start": 43,
"end": 45,
"loc": {
"start": {
"line": 2,
"column": 26
},
"end": {
"line": 2,
"column": 28
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
function fn(x = yield) {}

View File

@ -1,7 +1,7 @@
{
"type": "File",
"start": 0,
"end": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
@ -9,13 +9,13 @@
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"program": {
"type": "Program",
"start": 0,
"end": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
@ -23,7 +23,7 @@
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"sourceType": "script",
@ -31,7 +31,7 @@
{
"type": "FunctionDeclaration",
"start": 0,
"end": 24,
"end": 25,
"loc": {
"start": {
"line": 1,
@ -39,27 +39,27 @@
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"id": {
"type": "Identifier",
"start": 10,
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
"column": 9
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "g"
"identifierName": "fn"
},
"name": "g"
"name": "fn"
},
"generator": true,
"generator": false,
"expression": false,
"async": false,
"params": [
@ -115,16 +115,16 @@
],
"body": {
"type": "BlockStatement",
"start": 22,
"end": 24,
"start": 23,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
"column": 23
},
"end": {
"line": 1,
"column": 24
"column": 25
}
},
"body": [],

View File

@ -0,0 +1 @@
({ *method(x = yield) {} })

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in generator parameters (1:15)"
}

View File

@ -0,0 +1 @@
function* fn(x = yield) {}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in generator parameters (1:17)"
}

View File

@ -0,0 +1,2 @@
"use strict";
function fn(x = yield) {}

View File

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

View File

@ -0,0 +1,3 @@
function* fn() {
() => (yield) => {};
}

View File

@ -0,0 +1,178 @@
{
"type": "File",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 3,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 12,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 12
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": true,
"expression": false,
"async": false,
"params": [],
"body": {
"type": "BlockStatement",
"start": 15,
"end": 41,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 3,
"column": 1
}
},
"body": [
{
"type": "ExpressionStatement",
"start": 19,
"end": 39,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 22
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 19,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 21
}
},
"id": null,
"generator": false,
"expression": true,
"async": false,
"params": [],
"body": {
"type": "ArrowFunctionExpression",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 8
},
"end": {
"line": 2,
"column": 21
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 26,
"end": 31,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 14
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 36,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 21
}
},
"body": [],
"directives": []
}
}
}
}
],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1,3 @@
function* fn() {
(yield) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:3)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
(yield fn) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:3)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
(a, b, yield) => {};
}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:9)"
}

View File

@ -0,0 +1,3 @@
function* fn() {
yield => {};
}

View File

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

View File

@ -0,0 +1 @@
yield => {};

View File

@ -0,0 +1,104 @@
{
"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": 11,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 11
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 0,
"end": 5,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 5
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
(yield) => {}

View File

@ -0,0 +1,104 @@
{
"type": "File",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"sourceType": "script",
"body": [
{
"type": "ExpressionStatement",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"expression": {
"type": "ArrowFunctionExpression",
"start": 0,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 13
}
},
"id": null,
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 1,
"end": 6,
"loc": {
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 6
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 11,
"end": 13,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 13
}
},
"body": [],
"directives": []
}
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
function fn(yield) {}

View File

@ -0,0 +1,105 @@
{
"type": "File",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"program": {
"type": "Program",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"sourceType": "script",
"body": [
{
"type": "FunctionDeclaration",
"start": 0,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 21
}
},
"id": {
"type": "Identifier",
"start": 9,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 9
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "fn"
},
"name": "fn"
},
"generator": false,
"expression": false,
"async": false,
"params": [
{
"type": "Identifier",
"start": 12,
"end": 17,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 17
},
"identifierName": "yield"
},
"name": "yield"
}
],
"body": {
"type": "BlockStatement",
"start": 19,
"end": 21,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 21
}
},
"body": [],
"directives": []
}
}
],
"directives": []
}
}

View File

@ -0,0 +1 @@
({ *method(yield) {} });

View File

@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:11)"
}

View File

@ -0,0 +1 @@
function* fn(yield) {}

View File

@ -0,0 +1,3 @@
{
"throws": "yield is a reserved word inside generator functions (1:13)"
}

View File

@ -0,0 +1 @@
function fn(yield) { "use strict"; }

View File

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

View File

@ -0,0 +1,2 @@
"use strict";
function fn(yield) {}

View File

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

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