test262: test262/test/language/expressions/generators/yield-as-label.js
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Apr 2017 16:06:33 +0000 (16:06 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Apr 2017 16:06:33 +0000 (16:06 +0000)
commitc7195e64351e11ee98e4f88cfbe20344737a029d
tree0f43b958a79b18b362164cc0fa5b893defdfd914
parent6ba3f467ab708f59a5f4b01c8181addca2b97840
test262: test262/test/language/expressions/generators/yield-as-label.js
https://bugs.webkit.org/show_bug.cgi?id=170979

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2017-04-24
Reviewed by Saam Barati.

JSTests:

* stress/async-await-module-reserved-word.js:
* stress/async-await-reserved-word.js:
Converge on "Cannot" instead of "Can't".

* catch-parameter-syntax.js:
* yield-named-variable-generator.js:
* yield-named-variable.js:
* stress/yield-label-generator.js:
* stress/yield-label.js:
* stress/yield-reserved-word.js: Added.
More complete list of when 'yield' is allowed.

* ChakraCore/test/strict/23.reservedWords_sm.baseline-jsc:
* test262.yaml:

Source/JavaScriptCore:

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseVariableDeclarationList):
(JSC::Parser<LexerType>::parseDestructuringPattern):
(JSC::Parser<LexerType>::parseFormalParameters):
Converge on "Cannot" instead of "Can't" in error messages.

(JSC::Parser<LexerType>::parseFunctionInfo):
Disallow "yield" as the generator function name in function expressions.
This refers to the difference between Declaration and Expression, where
only GeneratorExpression explicitly has [+Yield] disallowing yield for
the generator name:

    GeneratorDeclaration[Yield, Await, Default]:
        function * BindingIdentifier[?Yield, ?Await] ...

    GeneratorExpression:
        function * BindingIdentifier[+Yield, ~Await]opt ...

(JSC::Parser<LexerType>::parseExpressionOrLabelStatement):
Disallow "yield" as a label name in strict mode or inside a generator.

(JSC::Parser<LexerType>::parseProperty):
Disallow "yield" or any keyword in object literal shorthands.

* parser/Parser.h:
(JSC::Parser::getToken):
(JSC::Parser::isDisallowedIdentifierLet):
(JSC::Parser::isDisallowedIdentifierYield):
(JSC::Parser::disallowedIdentifierLetReason):
(JSC::Parser::disallowedIdentifierYieldReason):
Follow pattern for improved error messages based on context.

LayoutTests:

* js/object-literal-shorthand-construction-expected.txt:
* js/script-tests/object-literal-shorthand-construction.js:
Extend this test to cover object literal shorthand with keywords.

* js/dom/reserved-words-as-property-expected.txt:
* js/let-syntax-expected.txt:
* js/parser-syntax-check-expected.txt:
Improved error messages.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
JSTests/ChakraCore/test/strict/23.reservedWords_sm.baseline-jsc
JSTests/ChangeLog
JSTests/stress/async-await-module-reserved-word.js
JSTests/stress/async-await-reserved-word.js
JSTests/stress/catch-parameter-syntax.js
JSTests/stress/yield-label-generator.js
JSTests/stress/yield-label.js
JSTests/stress/yield-named-variable-generator.js
JSTests/stress/yield-named-variable.js
JSTests/stress/yield-reserved-word.js [new file with mode: 0644]
JSTests/test262.yaml
LayoutTests/ChangeLog
LayoutTests/js/dom/reserved-words-as-property-expected.txt
LayoutTests/js/let-syntax-expected.txt
LayoutTests/js/object-literal-shorthand-construction-expected.txt
LayoutTests/js/parser-syntax-check-expected.txt
LayoutTests/js/script-tests/object-literal-shorthand-construction.js
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/parser/Parser.cpp
Source/JavaScriptCore/parser/Parser.h