From 1b612148bfee190cc05b0eb78d4c2b3537655c1c Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 1 Nov 2017 16:04:22 +0100 Subject: [PATCH] "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 --- scripts/flow_tests_whitelist.txt | 1 - scripts/test262_whitelist.txt | 19 -- src/parser/expression.js | 100 ++++++-- src/parser/statement.js | 27 ++- src/plugins/flow.js | 4 +- src/plugins/typescript.js | 4 +- src/tokenizer/state.js | 11 +- .../es2015/uncategorised/253/actual.js | 1 - .../es2015/uncategorised/254/options.json | 3 - .../100 => yield/asi}/actual.js | 0 .../100 => yield/asi}/expected.json | 0 .../100 => yield/asi}/options.json | 0 .../basic-with-argument}/actual.js | 0 .../basic-with-argument}/expected.json | 0 .../basic-with-argument}/options.json | 0 .../basic-without-argument}/actual.js | 0 .../basic-without-argument}/expected.json | 0 .../actual.js | 3 + .../options.json | 3 + .../actual.js | 1 + .../expected.json | 87 +++++++ .../actual.js | 3 + .../expected.json | 160 +++++++++++++ .../actual.js | 1 + .../expected.json | 122 ++++++++++ .../function-name-function-method/actual.js | 3 + .../expected.json | 141 +++++++++++ .../actual.js | 1 + .../expected.json | 87 +++++++ .../actual.js | 1 + .../options.json | 3 + .../function-name-generator-method/actual.js | 3 + .../expected.json | 141 +++++++++++ .../function-name-inside-function/actual.js | 3 + .../expected.json | 141 +++++++++++ .../yield/function-name-strict-body/actual.js | 1 + .../function-name-strict-body/options.json | 3 + .../yield/function-name-strict/actual.js | 2 + .../yield/function-name-strict/options.json | 3 + .../262 => yield/in-class-heritage}/actual.js | 0 .../in-class-heritage}/options.json | 0 .../254 => yield/in-global-scope}/actual.js | 0 .../in-global-scope}/options.json | 0 .../258 => yield/in-plain-function}/actual.js | 0 .../in-plain-function}/options.json | 0 .../inside-arrow-inside-generator/actual.js | 4 + .../expected.json | 225 ++++++++++++++++++ .../actual.js | 3 + .../expected.json | 210 ++++++++++++++++ .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../parameter-default-inside-arrow/actual.js | 1 + .../expected.json | 136 +++++++++++ .../actual.js | 3 + .../expected.json | 191 +++++++++++++++ .../actual.js | 1 + .../expected.json | 30 +-- .../actual.js | 1 + .../options.json | 3 + .../actual.js | 1 + .../options.json | 3 + .../yield/parameter-default-strict/actual.js | 2 + .../parameter-default-strict/options.json | 3 + .../actual.js | 3 + .../expected.json | 178 ++++++++++++++ .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../actual.js | 3 + .../options.json | 3 + .../parameter-name-arrow-no-parens/actual.js | 1 + .../expected.json | 104 ++++++++ .../yield/parameter-name-arrow/actual.js | 1 + .../yield/parameter-name-arrow/expected.json | 104 ++++++++ .../yield/parameter-name-function/actual.js | 1 + .../parameter-name-function/expected.json | 105 ++++++++ .../parameter-name-generator-method/actual.js | 1 + .../options.json | 3 + .../yield/parameter-name-generator/actual.js | 1 + .../parameter-name-generator/options.json | 3 + .../parameter-name-strict-body/actual.js | 1 + .../parameter-name-strict-body/options.json | 3 + .../yield/parameter-name-strict/actual.js | 2 + .../yield/parameter-name-strict/options.json | 3 + .../actual.js | 0 .../expected.json | 0 .../actual.js | 0 .../expected.json | 0 .../actual.js | 0 .../expected.json | 0 .../actual.js | 0 .../expected.json | 0 .../actual.js | 0 .../expected.json | 0 .../actual.js | 0 .../expected.json | 0 .../actual.js | 1 + .../expected.json | 170 +++++++++++++ .../actual.js | 1 + .../options.json | 3 + .../106 => yield/yield-yield}/actual.js | 0 .../106 => yield/yield-yield}/expected.json | 0 .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../options.json | 3 - .../actual.js | 0 .../options.json | 3 + .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../actual.js | 0 .../options.json | 3 + .../actual.js | 0 .../options.json | 3 + .../actual.js | 0 .../options.json | 3 + .../options.json | 2 +- .../options.json | 2 +- .../actual.js | 0 .../options.json | 3 + .../actual.js | 0 .../invalid-yield-generator-rest/options.json | 3 + .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../actual.js | 0 .../options.json | 3 + .../actual.js | 0 .../options.json | 3 + .../actual.js | 0 .../options.json | 3 + .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../options.json | 2 +- .../actual.js | 0 .../expected.json | 95 ++++---- .../options.json | 3 + .../actual.js | 1 - .../actual.js | 0 .../expected.json | 191 +++++++++++++++ .../actual.js | 0 .../expected.json | 193 +++++++++++++++ .../invalid-syntax/migrated_0231/options.json | 2 +- .../invalid-getter/actual.js | 3 + .../invalid-getter/options.json | 3 + .../invalid-setter/actual.js | 3 + .../invalid-setter/options.json | 3 + 171 files changed, 3067 insertions(+), 163 deletions(-) delete mode 100644 test/fixtures/es2015/uncategorised/253/actual.js delete mode 100644 test/fixtures/es2015/uncategorised/254/options.json rename test/fixtures/es2015/{uncategorised/100 => yield/asi}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/100 => yield/asi}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/100 => yield/asi}/options.json (100%) rename test/fixtures/es2015/{uncategorised/99 => yield/basic-with-argument}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/99 => yield/basic-with-argument}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/99 => yield/basic-with-argument}/options.json (100%) rename test/fixtures/es2015/{uncategorised/104 => yield/basic-without-argument}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/104 => yield/basic-without-argument}/expected.json (100%) create mode 100644 test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json create mode 100644 test/fixtures/es2015/yield/function-name-function-declaration/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-function-declaration/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-function-expression-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-function-expression-inside-generator/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-function-expression/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-function-expression/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-function-method/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-function-method/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-generator-declaration/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-generator-declaration/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-generator-expression/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-generator-expression/options.json create mode 100644 test/fixtures/es2015/yield/function-name-generator-method/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-generator-method/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-inside-function/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-inside-function/expected.json create mode 100644 test/fixtures/es2015/yield/function-name-strict-body/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-strict-body/options.json create mode 100644 test/fixtures/es2015/yield/function-name-strict/actual.js create mode 100644 test/fixtures/es2015/yield/function-name-strict/options.json rename test/fixtures/es2015/{uncategorised/262 => yield/in-class-heritage}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/262 => yield/in-class-heritage}/options.json (100%) rename test/fixtures/es2015/{uncategorised/254 => yield/in-global-scope}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/253 => yield/in-global-scope}/options.json (100%) rename test/fixtures/es2015/{uncategorised/258 => yield/in-plain-function}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/258 => yield/in-plain-function}/options.json (100%) create mode 100644 test/fixtures/es2015/yield/inside-arrow-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/inside-arrow-inside-generator/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-arrow/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-function/actual.js rename test/fixtures/{esprima/es2015-yield/yield-generator-default-parameter => es2015/yield/parameter-default-inside-function}/expected.json (87%) create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-generator-method/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-inside-generator/options.json create mode 100644 test/fixtures/es2015/yield/parameter-default-strict/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-default-strict/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-no-parens/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow-no-parens/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-arrow/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-name-function/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-function/expected.json create mode 100644 test/fixtures/es2015/yield/parameter-name-generator-method/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-generator-method/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-generator/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-generator/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-strict-body/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-strict-body/options.json create mode 100644 test/fixtures/es2015/yield/parameter-name-strict/actual.js create mode 100644 test/fixtures/es2015/yield/parameter-name-strict/options.json rename test/fixtures/es2015/{uncategorised/257 => yield/yield-star-in-arrow-scope-is-multiplication}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/257 => yield/yield-star-in-arrow-scope-is-multiplication}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/256 => yield/yield-star-in-global-scope-is-multiplication}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/256 => yield/yield-star-in-global-scope-is-multiplication}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/102 => yield/yield-star-inside-generator-function-declaration}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/102 => yield/yield-star-inside-generator-function-declaration}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/101 => yield/yield-star-inside-generator-function-expression}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/101 => yield/yield-star-inside-generator-function-expression}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/103 => yield/yield-star-inside-generator-method}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/103 => yield/yield-star-inside-generator-method}/expected.json (100%) rename test/fixtures/es2015/{uncategorised/259 => yield/yield-star-inside-plain-function}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/259 => yield/yield-star-inside-plain-function}/expected.json (100%) create mode 100644 test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/actual.js create mode 100644 test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/expected.json create mode 100644 test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/actual.js create mode 100644 test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json rename test/fixtures/es2015/{uncategorised/106 => yield/yield-yield}/actual.js (100%) rename test/fixtures/es2015/{uncategorised/106 => yield/yield-yield}/expected.json (100%) delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-generator-arrow-default/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-name/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-parameter/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-rest/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-generator-parameter/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-generator-rest/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-strict-array-pattern/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-default/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-name/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-generator-arrow-default => invalid-yield-generator-arrow-default}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-generator-expression-name => invalid-yield-generator-expression-name}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-generator-expression-parameter => invalid-yield-generator-expression-parameter}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-generator-expression-rest => invalid-yield-generator-expression-rest}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-generator-parameter => invalid-yield-generator-parameter}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-generator-rest => invalid-yield-generator-rest}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-strict-array-pattern => invalid-yield-strict-array-pattern}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-strict-arrow-parameter-default => invalid-yield-strict-arrow-parameter-default}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json rename test/fixtures/esprima/es2015-yield/{.invalid-yield-strict-arrow-parameter-name => invalid-yield-strict-arrow-parameter-name}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json rename test/fixtures/esprima/es2015-yield/{.yield-generator-arrow-concise-body => yield-generator-arrow-concise-body}/actual.js (100%) rename test/fixtures/esprima/es2015-yield/{yield-generator-arrow-default => yield-generator-arrow-concise-body}/expected.json (66%) create mode 100644 test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json delete mode 100644 test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/actual.js rename test/fixtures/esprima/es2015-yield/{.yield-generator-function-expression => yield-generator-function-expression}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/yield-generator-function-expression/expected.json rename test/fixtures/esprima/es2015-yield/{.yield-generator-function-parameter => yield-generator-function-parameter}/actual.js (100%) create mode 100644 test/fixtures/esprima/es2015-yield/yield-generator-function-parameter/expected.json create mode 100644 test/fixtures/flow/type-parameter-declaration/invalid-getter/actual.js create mode 100644 test/fixtures/flow/type-parameter-declaration/invalid-getter/options.json create mode 100644 test/fixtures/flow/type-parameter-declaration/invalid-setter/actual.js create mode 100644 test/fixtures/flow/type-parameter-declaration/invalid-setter/options.json diff --git a/scripts/flow_tests_whitelist.txt b/scripts/flow_tests_whitelist.txt index cf981ff080..b79939f313 100644 --- a/scripts/flow_tests_whitelist.txt +++ b/scripts/flow_tests_whitelist.txt @@ -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 diff --git a/scripts/test262_whitelist.txt b/scripts/test262_whitelist.txt index 2ce1c445aa..3b0dcc8366 100644 --- a/scripts/test262_whitelist.txt +++ b/scripts/test262_whitelist.txt @@ -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) diff --git a/src/parser/expression.js b/src/parser/expression.js index 08324f2b98..6213bcc1f8 100644 --- a/src/parser/expression.js +++ b/src/parser/expression.js @@ -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) || diff --git a/src/parser/statement.js b/src/parser/statement.js index 3f175b8a02..1147eea62b 100644 --- a/src/parser/statement.js +++ b/src/parser/statement.js @@ -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 diff --git a/src/plugins/flow.js b/src/plugins/flow.js index b3b04ecfbd..91c7a521dd 100644 --- a/src/plugins/flow.js +++ b/src/plugins/flow.js @@ -2002,7 +2002,9 @@ export default (superClass: Class): Class => // parse function type parameters - function foo() {} 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); diff --git a/src/plugins/typescript.js b/src/plugins/typescript.js index 47078f7e11..e1d13420c7 100644 --- a/src/plugins/typescript.js +++ b/src/plugins/typescript.js @@ -1679,10 +1679,10 @@ export default (superClass: Class): Class => 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;` diff --git a/src/tokenizer/state.js b/src/tokenizer/state.js index f5b585ed57..e2ad59f9f8 100644 --- a/src/tokenizer/state.js +++ b/src/tokenizer/state.js @@ -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>; + // 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; diff --git a/test/fixtures/es2015/uncategorised/253/actual.js b/test/fixtures/es2015/uncategorised/253/actual.js deleted file mode 100644 index 4cdfc5f6e3..0000000000 --- a/test/fixtures/es2015/uncategorised/253/actual.js +++ /dev/null @@ -1 +0,0 @@ -yield v \ No newline at end of file diff --git a/test/fixtures/es2015/uncategorised/254/options.json b/test/fixtures/es2015/uncategorised/254/options.json deleted file mode 100644 index ba6c2c68ee..0000000000 --- a/test/fixtures/es2015/uncategorised/254/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token, expected ; (1:6)" -} \ No newline at end of file diff --git a/test/fixtures/es2015/uncategorised/100/actual.js b/test/fixtures/es2015/yield/asi/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/100/actual.js rename to test/fixtures/es2015/yield/asi/actual.js diff --git a/test/fixtures/es2015/uncategorised/100/expected.json b/test/fixtures/es2015/yield/asi/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/100/expected.json rename to test/fixtures/es2015/yield/asi/expected.json diff --git a/test/fixtures/es2015/uncategorised/100/options.json b/test/fixtures/es2015/yield/asi/options.json similarity index 100% rename from test/fixtures/es2015/uncategorised/100/options.json rename to test/fixtures/es2015/yield/asi/options.json diff --git a/test/fixtures/es2015/uncategorised/99/actual.js b/test/fixtures/es2015/yield/basic-with-argument/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/99/actual.js rename to test/fixtures/es2015/yield/basic-with-argument/actual.js diff --git a/test/fixtures/es2015/uncategorised/99/expected.json b/test/fixtures/es2015/yield/basic-with-argument/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/99/expected.json rename to test/fixtures/es2015/yield/basic-with-argument/expected.json diff --git a/test/fixtures/es2015/uncategorised/99/options.json b/test/fixtures/es2015/yield/basic-with-argument/options.json similarity index 100% rename from test/fixtures/es2015/uncategorised/99/options.json rename to test/fixtures/es2015/yield/basic-with-argument/options.json diff --git a/test/fixtures/es2015/uncategorised/104/actual.js b/test/fixtures/es2015/yield/basic-without-argument/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/104/actual.js rename to test/fixtures/es2015/yield/basic-without-argument/actual.js diff --git a/test/fixtures/es2015/uncategorised/104/expected.json b/test/fixtures/es2015/yield/basic-without-argument/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/104/expected.json rename to test/fixtures/es2015/yield/basic-without-argument/expected.json diff --git a/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/actual.js b/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/actual.js new file mode 100644 index 0000000000..53d5d740cb --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/actual.js @@ -0,0 +1,3 @@ +function* fn() { + function yield() {} +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json b/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json new file mode 100644 index 0000000000..4b0c86bb67 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-declaration-inside-generator/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (2:11)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-declaration/actual.js b/test/fixtures/es2015/yield/function-name-function-declaration/actual.js new file mode 100644 index 0000000000..7f570d523d --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-declaration/actual.js @@ -0,0 +1 @@ +function yield() {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-declaration/expected.json b/test/fixtures/es2015/yield/function-name-function-declaration/expected.json new file mode 100644 index 0000000000..48c7abd934 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-declaration/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-expression-inside-generator/actual.js b/test/fixtures/es2015/yield/function-name-function-expression-inside-generator/actual.js new file mode 100644 index 0000000000..07d65aaac1 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-expression-inside-generator/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (function yield() {}); +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-expression-inside-generator/expected.json b/test/fixtures/es2015/yield/function-name-function-expression-inside-generator/expected.json new file mode 100644 index 0000000000..adb52158c7 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-expression-inside-generator/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-expression/actual.js b/test/fixtures/es2015/yield/function-name-function-expression/actual.js new file mode 100644 index 0000000000..bb665d8bea --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-expression/actual.js @@ -0,0 +1 @@ ++function yield() {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-expression/expected.json b/test/fixtures/es2015/yield/function-name-function-expression/expected.json new file mode 100644 index 0000000000..f9d6ec61df --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-expression/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-method/actual.js b/test/fixtures/es2015/yield/function-name-function-method/actual.js new file mode 100644 index 0000000000..3b6b6e3afb --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-method/actual.js @@ -0,0 +1,3 @@ +class A { + yield() {} +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-function-method/expected.json b/test/fixtures/es2015/yield/function-name-function-method/expected.json new file mode 100644 index 0000000000..e6f2fa5700 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-function-method/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-generator-declaration/actual.js b/test/fixtures/es2015/yield/function-name-generator-declaration/actual.js new file mode 100644 index 0000000000..9dcc776041 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-generator-declaration/actual.js @@ -0,0 +1 @@ +function* yield() {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-generator-declaration/expected.json b/test/fixtures/es2015/yield/function-name-generator-declaration/expected.json new file mode 100644 index 0000000000..fa5c096371 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-generator-declaration/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-generator-expression/actual.js b/test/fixtures/es2015/yield/function-name-generator-expression/actual.js new file mode 100644 index 0000000000..fc1d04a290 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-generator-expression/actual.js @@ -0,0 +1 @@ ++function* yield() {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-generator-expression/options.json b/test/fixtures/es2015/yield/function-name-generator-expression/options.json new file mode 100644 index 0000000000..66bd72acf9 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-generator-expression/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:11)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-generator-method/actual.js b/test/fixtures/es2015/yield/function-name-generator-method/actual.js new file mode 100644 index 0000000000..20b3d1239b --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-generator-method/actual.js @@ -0,0 +1,3 @@ +class A { + *yield() {} +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-generator-method/expected.json b/test/fixtures/es2015/yield/function-name-generator-method/expected.json new file mode 100644 index 0000000000..6cc8417dd6 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-generator-method/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-inside-function/actual.js b/test/fixtures/es2015/yield/function-name-inside-function/actual.js new file mode 100644 index 0000000000..1e3f513408 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-inside-function/actual.js @@ -0,0 +1,3 @@ +function fn() { + function yield() {} +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-inside-function/expected.json b/test/fixtures/es2015/yield/function-name-inside-function/expected.json new file mode 100644 index 0000000000..cb8604acf3 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-inside-function/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-strict-body/actual.js b/test/fixtures/es2015/yield/function-name-strict-body/actual.js new file mode 100644 index 0000000000..110afcce54 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-strict-body/actual.js @@ -0,0 +1 @@ +function yield() { "use strict"; } \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-strict-body/options.json b/test/fixtures/es2015/yield/function-name-strict-body/options.json new file mode 100644 index 0000000000..46f9bcac4a --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-strict-body/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (1:9)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-strict/actual.js b/test/fixtures/es2015/yield/function-name-strict/actual.js new file mode 100644 index 0000000000..64c66de4e3 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-strict/actual.js @@ -0,0 +1,2 @@ +"use strict"; +function yield() {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/function-name-strict/options.json b/test/fixtures/es2015/yield/function-name-strict/options.json new file mode 100644 index 0000000000..b16b4e8cd5 --- /dev/null +++ b/test/fixtures/es2015/yield/function-name-strict/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (2:9)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/uncategorised/262/actual.js b/test/fixtures/es2015/yield/in-class-heritage/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/262/actual.js rename to test/fixtures/es2015/yield/in-class-heritage/actual.js diff --git a/test/fixtures/es2015/uncategorised/262/options.json b/test/fixtures/es2015/yield/in-class-heritage/options.json similarity index 100% rename from test/fixtures/es2015/uncategorised/262/options.json rename to test/fixtures/es2015/yield/in-class-heritage/options.json diff --git a/test/fixtures/es2015/uncategorised/254/actual.js b/test/fixtures/es2015/yield/in-global-scope/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/254/actual.js rename to test/fixtures/es2015/yield/in-global-scope/actual.js diff --git a/test/fixtures/es2015/uncategorised/253/options.json b/test/fixtures/es2015/yield/in-global-scope/options.json similarity index 100% rename from test/fixtures/es2015/uncategorised/253/options.json rename to test/fixtures/es2015/yield/in-global-scope/options.json diff --git a/test/fixtures/es2015/uncategorised/258/actual.js b/test/fixtures/es2015/yield/in-plain-function/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/258/actual.js rename to test/fixtures/es2015/yield/in-plain-function/actual.js diff --git a/test/fixtures/es2015/uncategorised/258/options.json b/test/fixtures/es2015/yield/in-plain-function/options.json similarity index 100% rename from test/fixtures/es2015/uncategorised/258/options.json rename to test/fixtures/es2015/yield/in-plain-function/options.json diff --git a/test/fixtures/es2015/yield/inside-arrow-inside-generator/actual.js b/test/fixtures/es2015/yield/inside-arrow-inside-generator/actual.js new file mode 100644 index 0000000000..6021485eb8 --- /dev/null +++ b/test/fixtures/es2015/yield/inside-arrow-inside-generator/actual.js @@ -0,0 +1,4 @@ +function* fn() { + () => yield; + () => { yield }; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/inside-arrow-inside-generator/expected.json b/test/fixtures/es2015/yield/inside-arrow-inside-generator/expected.json new file mode 100644 index 0000000000..274481edfd --- /dev/null +++ b/test/fixtures/es2015/yield/inside-arrow-inside-generator/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/actual.js new file mode 100644 index 0000000000..40277a7a96 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/actual.js @@ -0,0 +1,3 @@ +function* fn() { + () => (x = yield) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/expected.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/expected.json new file mode 100644 index 0000000000..fb243454e0 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-arrow-inside-generator/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/actual.js new file mode 100644 index 0000000000..f83e5dab3c --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (x = yield) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json new file mode 100644 index 0000000000..f03cb0d173 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-1/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:7)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/actual.js new file mode 100644 index 0000000000..194d0c1b3e --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (x = 3 + a.b(yield) ** 2) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json new file mode 100644 index 0000000000..ab6d176e8a --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-2/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:15)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/actual.js new file mode 100644 index 0000000000..62facbdc7e --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (x = yield fn) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json new file mode 100644 index 0000000000..f03cb0d173 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-3/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:7)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/actual.js new file mode 100644 index 0000000000..cd813eabbd --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (a, b = 3, x = yield) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json new file mode 100644 index 0000000000..2735e958a9 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-4/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:17)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/actual.js new file mode 100644 index 0000000000..43c81a2c31 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (x = (yield) => {}) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json new file mode 100644 index 0000000000..816f0c4579 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow-inside-generator-5/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:8)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-arrow/actual.js new file mode 100644 index 0000000000..8be1ee0433 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow/actual.js @@ -0,0 +1 @@ +(x = yield) => {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-arrow/expected.json b/test/fixtures/es2015/yield/parameter-default-inside-arrow/expected.json new file mode 100644 index 0000000000..4e9be7eb6c --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-arrow/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/actual.js new file mode 100644 index 0000000000..b228508b9b --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/actual.js @@ -0,0 +1,3 @@ +function* fn() { + function fn2(x = yield) {} +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/expected.json b/test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/expected.json new file mode 100644 index 0000000000..a0e97b21b0 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-function-inside-generator/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-function/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-function/actual.js new file mode 100644 index 0000000000..50e43494e0 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-function/actual.js @@ -0,0 +1 @@ +function fn(x = yield) {} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/expected.json b/test/fixtures/es2015/yield/parameter-default-inside-function/expected.json similarity index 87% rename from test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/expected.json rename to test/fixtures/es2015/yield/parameter-default-inside-function/expected.json index d9dc1ed5e4..cc2cd47467 100644 --- a/test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/expected.json +++ b/test/fixtures/es2015/yield/parameter-default-inside-function/expected.json @@ -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": [], diff --git a/test/fixtures/es2015/yield/parameter-default-inside-generator-method/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-generator-method/actual.js new file mode 100644 index 0000000000..8e5ec0585a --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-generator-method/actual.js @@ -0,0 +1 @@ +({ *method(x = yield) {} }) \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json b/test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json new file mode 100644 index 0000000000..163f3e8629 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-generator-method/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in generator parameters (1:15)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-generator/actual.js b/test/fixtures/es2015/yield/parameter-default-inside-generator/actual.js new file mode 100644 index 0000000000..76162b07de --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-generator/actual.js @@ -0,0 +1 @@ +function* fn(x = yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-inside-generator/options.json b/test/fixtures/es2015/yield/parameter-default-inside-generator/options.json new file mode 100644 index 0000000000..6803713092 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-inside-generator/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in generator parameters (1:17)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-strict/actual.js b/test/fixtures/es2015/yield/parameter-default-strict/actual.js new file mode 100644 index 0000000000..0c2b6a724d --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-strict/actual.js @@ -0,0 +1,2 @@ +"use strict"; +function fn(x = yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-default-strict/options.json b/test/fixtures/es2015/yield/parameter-default-strict/options.json new file mode 100644 index 0000000000..5c6c0a252a --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-default-strict/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (2:16)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/actual.js new file mode 100644 index 0000000000..78ebd6f621 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/actual.js @@ -0,0 +1,3 @@ +function* fn() { + () => (yield) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/expected.json b/test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/expected.json new file mode 100644 index 0000000000..196e931a5a --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-arrow-inside-generator/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/actual.js new file mode 100644 index 0000000000..ccba2758d2 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (yield) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json new file mode 100644 index 0000000000..cd9b403bd9 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-1/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:3)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/actual.js new file mode 100644 index 0000000000..3f1ea27ae7 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (yield fn) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json new file mode 100644 index 0000000000..cd9b403bd9 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-2/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:3)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/actual.js new file mode 100644 index 0000000000..dd0014f793 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/actual.js @@ -0,0 +1,3 @@ +function* fn() { + (a, b, yield) => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json new file mode 100644 index 0000000000..584d09b5ff --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-inside-generator-3/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (2:9)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/actual.js new file mode 100644 index 0000000000..c46b294be6 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/actual.js @@ -0,0 +1,3 @@ +function* fn() { + yield => {}; +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/options.json b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/options.json new file mode 100644 index 0000000000..7e3689b6c6 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens-inside-generator/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ; (2:8)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-no-parens/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens/actual.js new file mode 100644 index 0000000000..0e325ab55f --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens/actual.js @@ -0,0 +1 @@ +yield => {}; \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow-no-parens/expected.json b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens/expected.json new file mode 100644 index 0000000000..e9f9206b36 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow-no-parens/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow/actual.js b/test/fixtures/es2015/yield/parameter-name-arrow/actual.js new file mode 100644 index 0000000000..a761c58ddd --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow/actual.js @@ -0,0 +1 @@ +(yield) => {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-arrow/expected.json b/test/fixtures/es2015/yield/parameter-name-arrow/expected.json new file mode 100644 index 0000000000..6dfa746d3a --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-arrow/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-function/actual.js b/test/fixtures/es2015/yield/parameter-name-function/actual.js new file mode 100644 index 0000000000..7f131b41b6 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-function/actual.js @@ -0,0 +1 @@ +function fn(yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-function/expected.json b/test/fixtures/es2015/yield/parameter-name-function/expected.json new file mode 100644 index 0000000000..9ac15233bb --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-function/expected.json @@ -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": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-generator-method/actual.js b/test/fixtures/es2015/yield/parameter-name-generator-method/actual.js new file mode 100644 index 0000000000..68e6ffdcb1 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-generator-method/actual.js @@ -0,0 +1 @@ +({ *method(yield) {} }); \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-generator-method/options.json b/test/fixtures/es2015/yield/parameter-name-generator-method/options.json new file mode 100644 index 0000000000..66bd72acf9 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-generator-method/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:11)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-generator/actual.js b/test/fixtures/es2015/yield/parameter-name-generator/actual.js new file mode 100644 index 0000000000..5da3462a38 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-generator/actual.js @@ -0,0 +1 @@ +function* fn(yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-generator/options.json b/test/fixtures/es2015/yield/parameter-name-generator/options.json new file mode 100644 index 0000000000..e7d3ccac20 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-generator/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:13)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-strict-body/actual.js b/test/fixtures/es2015/yield/parameter-name-strict-body/actual.js new file mode 100644 index 0000000000..364fb6fcf7 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-strict-body/actual.js @@ -0,0 +1 @@ +function fn(yield) { "use strict"; } \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-strict-body/options.json b/test/fixtures/es2015/yield/parameter-name-strict-body/options.json new file mode 100644 index 0000000000..9abfaf5e09 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-strict-body/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (1:12)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-strict/actual.js b/test/fixtures/es2015/yield/parameter-name-strict/actual.js new file mode 100644 index 0000000000..a5550724f4 --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-strict/actual.js @@ -0,0 +1,2 @@ +"use strict"; +function fn(yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/parameter-name-strict/options.json b/test/fixtures/es2015/yield/parameter-name-strict/options.json new file mode 100644 index 0000000000..cc99c7829c --- /dev/null +++ b/test/fixtures/es2015/yield/parameter-name-strict/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (2:12)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/uncategorised/257/actual.js b/test/fixtures/es2015/yield/yield-star-in-arrow-scope-is-multiplication/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/257/actual.js rename to test/fixtures/es2015/yield/yield-star-in-arrow-scope-is-multiplication/actual.js diff --git a/test/fixtures/es2015/uncategorised/257/expected.json b/test/fixtures/es2015/yield/yield-star-in-arrow-scope-is-multiplication/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/257/expected.json rename to test/fixtures/es2015/yield/yield-star-in-arrow-scope-is-multiplication/expected.json diff --git a/test/fixtures/es2015/uncategorised/256/actual.js b/test/fixtures/es2015/yield/yield-star-in-global-scope-is-multiplication/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/256/actual.js rename to test/fixtures/es2015/yield/yield-star-in-global-scope-is-multiplication/actual.js diff --git a/test/fixtures/es2015/uncategorised/256/expected.json b/test/fixtures/es2015/yield/yield-star-in-global-scope-is-multiplication/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/256/expected.json rename to test/fixtures/es2015/yield/yield-star-in-global-scope-is-multiplication/expected.json diff --git a/test/fixtures/es2015/uncategorised/102/actual.js b/test/fixtures/es2015/yield/yield-star-inside-generator-function-declaration/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/102/actual.js rename to test/fixtures/es2015/yield/yield-star-inside-generator-function-declaration/actual.js diff --git a/test/fixtures/es2015/uncategorised/102/expected.json b/test/fixtures/es2015/yield/yield-star-inside-generator-function-declaration/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/102/expected.json rename to test/fixtures/es2015/yield/yield-star-inside-generator-function-declaration/expected.json diff --git a/test/fixtures/es2015/uncategorised/101/actual.js b/test/fixtures/es2015/yield/yield-star-inside-generator-function-expression/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/101/actual.js rename to test/fixtures/es2015/yield/yield-star-inside-generator-function-expression/actual.js diff --git a/test/fixtures/es2015/uncategorised/101/expected.json b/test/fixtures/es2015/yield/yield-star-inside-generator-function-expression/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/101/expected.json rename to test/fixtures/es2015/yield/yield-star-inside-generator-function-expression/expected.json diff --git a/test/fixtures/es2015/uncategorised/103/actual.js b/test/fixtures/es2015/yield/yield-star-inside-generator-method/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/103/actual.js rename to test/fixtures/es2015/yield/yield-star-inside-generator-method/actual.js diff --git a/test/fixtures/es2015/uncategorised/103/expected.json b/test/fixtures/es2015/yield/yield-star-inside-generator-method/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/103/expected.json rename to test/fixtures/es2015/yield/yield-star-inside-generator-method/expected.json diff --git a/test/fixtures/es2015/uncategorised/259/actual.js b/test/fixtures/es2015/yield/yield-star-inside-plain-function/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/259/actual.js rename to test/fixtures/es2015/yield/yield-star-inside-plain-function/actual.js diff --git a/test/fixtures/es2015/uncategorised/259/expected.json b/test/fixtures/es2015/yield/yield-star-inside-plain-function/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/259/expected.json rename to test/fixtures/es2015/yield/yield-star-inside-plain-function/expected.json diff --git a/test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/actual.js b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/actual.js new file mode 100644 index 0000000000..18a8a8c231 --- /dev/null +++ b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/actual.js @@ -0,0 +1 @@ +function fn(x = yield* yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/expected.json b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/expected.json new file mode 100644 index 0000000000..3a1b23b0fb --- /dev/null +++ b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-function/expected.json @@ -0,0 +1,170 @@ +{ + "type": "File", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "sourceType": "script", + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "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": "AssignmentPattern", + "start": 12, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "left": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "x" + }, + "name": "x" + }, + "right": { + "type": "BinaryExpression", + "start": 16, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "left": { + "type": "Identifier", + "start": 16, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "operator": "*", + "right": { + "type": "Identifier", + "start": 23, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 28 + }, + "identifierName": "yield" + }, + "name": "yield" + } + } + } + ], + "body": { + "type": "BlockStatement", + "start": 30, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 32 + } + }, + "body": [], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/actual.js b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/actual.js new file mode 100644 index 0000000000..6d2d97e999 --- /dev/null +++ b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/actual.js @@ -0,0 +1 @@ +function* fn(x = yield* yield) {} \ No newline at end of file diff --git a/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json new file mode 100644 index 0000000000..6803713092 --- /dev/null +++ b/test/fixtures/es2015/yield/yield-star-parameter-default-inside-generator/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in generator parameters (1:17)" +} \ No newline at end of file diff --git a/test/fixtures/es2015/uncategorised/106/actual.js b/test/fixtures/es2015/yield/yield-yield/actual.js similarity index 100% rename from test/fixtures/es2015/uncategorised/106/actual.js rename to test/fixtures/es2015/yield/yield-yield/actual.js diff --git a/test/fixtures/es2015/uncategorised/106/expected.json b/test/fixtures/es2015/yield/yield-yield/expected.json similarity index 100% rename from test/fixtures/es2015/uncategorised/106/expected.json rename to test/fixtures/es2015/yield/yield-yield/expected.json diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-arrow-default/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-arrow-default/options.json deleted file mode 100644 index cbc444ce90..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-arrow-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:32)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-name/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-name/options.json deleted file mode 100644 index 328b1ddde8..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-name/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:10)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-parameter/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-parameter/options.json deleted file mode 100644 index 358068a16a..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:12)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-rest/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-rest/options.json deleted file mode 100644 index 2a73699bc2..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:18)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-parameter/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-parameter/options.json deleted file mode 100644 index 358068a16a..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-parameter/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:12)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-rest/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-rest/options.json deleted file mode 100644 index 0c5f4deed6..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-rest/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:24)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-array-pattern/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-array-pattern/options.json deleted file mode 100644 index 8fee4a64fa..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-array-pattern/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Assigning to yield in strict mode (1:16)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-default/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-default/options.json deleted file mode 100644 index aca079ee39..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-default/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Unexpected token (1:20)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-name/options.json b/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-name/options.json deleted file mode 100644 index c72d3f77b2..0000000000 --- a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-name/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "Binding yield in strict mode (1:15)" -} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-arrow-default/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-generator-arrow-default/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json new file mode 100644 index 0000000000..d84cec7b2d --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-default/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (1:21)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json index 1c860a7eb9..e354d58b31 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameter/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid left-hand side in arrow function parameters (1:16)" + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (1:16)" } \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json index 92cc34a930..2c82a8fe86 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-arrow-parameters/options.json @@ -1,3 +1,3 @@ { - "throws": "Invalid left-hand side in arrow function parameters (1:25)" + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (1:25)" } \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json index 5ebcbbe858..f6b6c33f1a 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-catch/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:30)" + "throws": "yield is a reserved word inside generator functions (1:30)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json index f0d1a6cf1a..afe3c715ca 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:26)" + "throws": "yield is a reserved word inside generator functions (1:26)" } diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-name/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-name/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json new file mode 100644 index 0000000000..7c3fd48ca3 --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-name/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:10)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-parameter/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-parameter/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json new file mode 100644 index 0000000000..4d161ba35a --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-parameter/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:12)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-rest/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-generator-expression-rest/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json new file mode 100644 index 0000000000..594d686a64 --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-expression-rest/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:18)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json index 4e58c050ba..c6514361e1 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-function-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:25)" + "throws": "yield is a reserved word inside generator functions (1:25)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json index ab645bdf60..f5e8c7d85f 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-lexical-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:20)" + "throws": "yield is a reserved word inside generator functions (1:20)" } diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-parameter/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-generator-parameter/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json new file mode 100644 index 0000000000..4d161ba35a --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-parameter/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:12)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-generator-rest/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-generator-rest/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json new file mode 100644 index 0000000000..853fd57f2e --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-rest/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word inside generator functions (1:24)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json index 55db1979e6..5255751472 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-expression/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:46)" + "throws": "yield is a reserved word in strict mode (1:46)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json index f4504039ab..4fab5560e7 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-strict-function-parameter/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:47)" + "throws": "yield is a reserved word in strict mode (1:47)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json index ab645bdf60..f5e8c7d85f 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-generator-variable-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:20)" + "throws": "yield is a reserved word inside generator functions (1:20)" } diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-array-pattern/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-strict-array-pattern/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json new file mode 100644 index 0000000000..6478b65d8d --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-array-pattern/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (1:16)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-default/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-default/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json new file mode 100644 index 0000000000..4a2737b8e9 --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-default/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (1:19)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-name/actual.js b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.invalid-yield-strict-arrow-parameter-name/actual.js rename to test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/actual.js diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json new file mode 100644 index 0000000000..5b44b14828 --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-arrow-parameter-name/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is a reserved word in strict mode (1:15)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json index b29ca62b42..997d8d34da 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-binding-element/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:23)" + "throws": "yield is a reserved word in strict mode (1:23)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json index 5d2e075e37..84c444f0cd 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-catch-parameter/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:28)" + "throws": "yield is a reserved word in strict mode (1:28)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json index 4e58c050ba..eadb012401 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-formal-parameter/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:25)" + "throws": "yield is a reserved word in strict mode (1:25)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json index ce6a7da479..cf06e871cc 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "Binding yield in strict mode (1:9)" + "throws": "yield is a reserved word in strict mode (1:9)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json index 95d52f45f5..c0b0db5cc9 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-function-expression/options.json @@ -1,3 +1,3 @@ { - "throws": "Binding yield in strict mode (1:10)" + "throws": "yield is a reserved word in strict mode (1:10)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json index 36e90ef404..0fa96eb13c 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-identifier/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:29)" + "throws": "yield is a reserved word in strict mode (1:29)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json index a6620a0567..773a6f2a5d 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-lexical-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:18)" + "throws": "yield is a reserved word in strict mode (1:18)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json index 5d2e075e37..84c444f0cd 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-rest-parameter/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:28)" + "throws": "yield is a reserved word in strict mode (1:28)" } diff --git a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json index a6620a0567..773a6f2a5d 100644 --- a/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json +++ b/test/fixtures/esprima/es2015-yield/invalid-yield-strict-variable-declaration/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:18)" + "throws": "yield is a reserved word in strict mode (1:18)" } diff --git a/test/fixtures/esprima/es2015-yield/.yield-generator-arrow-concise-body/actual.js b/test/fixtures/esprima/es2015-yield/yield-generator-arrow-concise-body/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.yield-generator-arrow-concise-body/actual.js rename to test/fixtures/esprima/es2015-yield/yield-generator-arrow-concise-body/actual.js diff --git a/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/expected.json b/test/fixtures/esprima/es2015-yield/yield-generator-arrow-concise-body/expected.json similarity index 66% rename from test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/expected.json rename to test/fixtures/esprima/es2015-yield/yield-generator-arrow-concise-body/expected.json index 92d1ed64ad..aa434f16dc 100644 --- a/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/expected.json +++ b/test/fixtures/esprima/es2015-yield/yield-generator-arrow-concise-body/expected.json @@ -95,7 +95,7 @@ "expression": { "type": "ArrowFunctionExpression", "start": 16, - "end": 33, + "end": 32, "loc": { "start": { "line": 1, @@ -103,18 +103,18 @@ }, "end": { "line": 1, - "column": 33 + "column": 32 } }, "id": null, "generator": false, - "expression": false, + "expression": true, "async": false, "params": [ { - "type": "AssignmentPattern", + "type": "Identifier", "start": 17, - "end": 26, + "end": 18, "loc": { "start": { "line": 1, @@ -122,61 +122,62 @@ }, "end": { "line": 1, - "column": 26 - } - }, - "left": { - "type": "Identifier", - "start": 17, - "end": 18, - "loc": { - "start": { - "line": 1, - "column": 17 - }, - "end": { - "line": 1, - "column": 18 - }, - "identifierName": "x" + "column": 18 }, - "name": "x" + "identifierName": "x" }, - "right": { - "type": "YieldExpression", - "start": 21, - "end": 26, - "loc": { - "start": { - "line": 1, - "column": 21 - }, - "end": { - "line": 1, - "column": 26 - } - }, - "delegate": false, - "argument": null - } + "name": "x" } ], "body": { - "type": "BlockStatement", - "start": 31, - "end": 33, + "type": "BinaryExpression", + "start": 23, + "end": 32, "loc": { "start": { "line": 1, - "column": 31 + "column": 23 }, "end": { "line": 1, - "column": 33 + "column": 32 } }, - "body": [], - "directives": [] + "left": { + "type": "Identifier", + "start": 23, + "end": 24, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 24 + }, + "identifierName": "x" + }, + "name": "x" + }, + "operator": "*", + "right": { + "type": "Identifier", + "start": 27, + "end": 32, + "loc": { + "start": { + "line": 1, + "column": 27 + }, + "end": { + "line": 1, + "column": 32 + }, + "identifierName": "yield" + }, + "name": "yield" + } } } } diff --git a/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json b/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json new file mode 100644 index 0000000000..d84cec7b2d --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/yield-generator-arrow-default/options.json @@ -0,0 +1,3 @@ +{ + "throws": "yield is not allowed in the parameters of an arrow function inside a generator (1:21)" +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/actual.js b/test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/actual.js deleted file mode 100644 index 98b544c1c1..0000000000 --- a/test/fixtures/esprima/es2015-yield/yield-generator-default-parameter/actual.js +++ /dev/null @@ -1 +0,0 @@ -function *g(x = yield){} diff --git a/test/fixtures/esprima/es2015-yield/.yield-generator-function-expression/actual.js b/test/fixtures/esprima/es2015-yield/yield-generator-function-expression/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.yield-generator-function-expression/actual.js rename to test/fixtures/esprima/es2015-yield/yield-generator-function-expression/actual.js diff --git a/test/fixtures/esprima/es2015-yield/yield-generator-function-expression/expected.json b/test/fixtures/esprima/es2015-yield/yield-generator-function-expression/expected.json new file mode 100644 index 0000000000..dfddec406d --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/yield-generator-function-expression/expected.json @@ -0,0 +1,191 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "sourceType": "script", + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 13, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 15, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 19, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 19, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 20 + }, + "identifierName": "y" + }, + "name": "y" + }, + "init": { + "type": "FunctionExpression", + "start": 23, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 23 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "id": { + "type": "Identifier", + "start": 32, + "end": 37, + "loc": { + "start": { + "line": 1, + "column": 32 + }, + "end": { + "line": 1, + "column": 37 + }, + "identifierName": "yield" + }, + "name": "yield" + }, + "generator": false, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 39, + "end": 41, + "loc": { + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 41 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/esprima/es2015-yield/.yield-generator-function-parameter/actual.js b/test/fixtures/esprima/es2015-yield/yield-generator-function-parameter/actual.js similarity index 100% rename from test/fixtures/esprima/es2015-yield/.yield-generator-function-parameter/actual.js rename to test/fixtures/esprima/es2015-yield/yield-generator-function-parameter/actual.js diff --git a/test/fixtures/esprima/es2015-yield/yield-generator-function-parameter/expected.json b/test/fixtures/esprima/es2015-yield/yield-generator-function-parameter/expected.json new file mode 100644 index 0000000000..553f0518f2 --- /dev/null +++ b/test/fixtures/esprima/es2015-yield/yield-generator-function-parameter/expected.json @@ -0,0 +1,193 @@ +{ + "type": "File", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "sourceType": "script", + "body": [ + { + "type": "FunctionDeclaration", + "start": 0, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "id": { + "type": "Identifier", + "start": 10, + "end": 11, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 11 + }, + "identifierName": "g" + }, + "name": "g" + }, + "generator": true, + "expression": false, + "async": false, + "params": [], + "body": { + "type": "BlockStatement", + "start": 14, + "end": 44, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "body": [ + { + "type": "VariableDeclaration", + "start": 16, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 20, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "id": { + "type": "Identifier", + "start": 20, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 20 + }, + "end": { + "line": 1, + "column": 21 + }, + "identifierName": "z" + }, + "name": "z" + }, + "init": { + "type": "FunctionExpression", + "start": 24, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "id": null, + "generator": false, + "expression": false, + "async": false, + "params": [ + { + "type": "Identifier", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 1, + "column": 33 + }, + "end": { + "line": 1, + "column": 38 + }, + "identifierName": "yield" + }, + "name": "yield" + } + ], + "body": { + "type": "BlockStatement", + "start": 40, + "end": 42, + "loc": { + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "body": [], + "directives": [] + } + } + } + ], + "kind": "var" + } + ], + "directives": [] + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json b/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json index 1edd04b2e0..b31373dfb7 100644 --- a/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json +++ b/test/fixtures/esprima/invalid-syntax/migrated_0231/options.json @@ -1,3 +1,3 @@ { - "throws": "yield is a reserved word (1:37)" + "throws": "yield is a reserved word in strict mode (1:37)" } diff --git a/test/fixtures/flow/type-parameter-declaration/invalid-getter/actual.js b/test/fixtures/flow/type-parameter-declaration/invalid-getter/actual.js new file mode 100644 index 0000000000..736ca7c6e0 --- /dev/null +++ b/test/fixtures/flow/type-parameter-declaration/invalid-getter/actual.js @@ -0,0 +1,3 @@ +const obj = { + get prop() {}, +}; \ No newline at end of file diff --git a/test/fixtures/flow/type-parameter-declaration/invalid-getter/options.json b/test/fixtures/flow/type-parameter-declaration/invalid-getter/options.json new file mode 100644 index 0000000000..0685750310 --- /dev/null +++ b/test/fixtures/flow/type-parameter-declaration/invalid-getter/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ( (2:10)" +} \ No newline at end of file diff --git a/test/fixtures/flow/type-parameter-declaration/invalid-setter/actual.js b/test/fixtures/flow/type-parameter-declaration/invalid-setter/actual.js new file mode 100644 index 0000000000..944122dfac --- /dev/null +++ b/test/fixtures/flow/type-parameter-declaration/invalid-setter/actual.js @@ -0,0 +1,3 @@ +const obj = { + set prop(a) {}, +}; \ No newline at end of file diff --git a/test/fixtures/flow/type-parameter-declaration/invalid-setter/options.json b/test/fixtures/flow/type-parameter-declaration/invalid-setter/options.json new file mode 100644 index 0000000000..0685750310 --- /dev/null +++ b/test/fixtures/flow/type-parameter-declaration/invalid-setter/options.json @@ -0,0 +1,3 @@ +{ + "throws": "Unexpected token, expected ( (2:10)" +} \ No newline at end of file