Diff
Modified: trunk/JSTests/ChangeLog (249924 => 249925)
--- trunk/JSTests/ChangeLog 2019-09-16 22:40:50 UTC (rev 249924)
+++ trunk/JSTests/ChangeLog 2019-09-16 22:56:08 UTC (rev 249925)
@@ -1,3 +1,17 @@
+2019-09-16 Ross Kirsling <ross.kirsl...@sony.com>
+
+ [JSC] Add missing syntax errors for await in function parameter default expressions
+ https://bugs.webkit.org/show_bug.cgi?id=201615
+
+ Reviewed by Darin Adler.
+
+ * stress/async-await-reserved-word.js:
+ * stress/async-await-syntax.js:
+ Add test cases.
+
+ * test262/expectations.yaml:
+ Mark newly-passing test cases.
+
2019-09-16 Saam Barati <sbar...@apple.com>
JSObject::putInlineSlow should not ignore "__proto__" for Proxy
Modified: trunk/JSTests/stress/async-await-reserved-word.js (249924 => 249925)
--- trunk/JSTests/stress/async-await-reserved-word.js 2019-09-16 22:40:50 UTC (rev 249924)
+++ trunk/JSTests/stress/async-await-reserved-word.js 2019-09-16 22:56:08 UTC (rev 249925)
@@ -48,6 +48,9 @@
shouldThrowSyntaxError("(async function f(...await) {})", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("(async function f({await}) {})", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("(async function f({isAsync: await}) {})", "Cannot use 'await' as a parameter name in an async function.");
+shouldThrowSyntaxError("(async function f(x = await => {}) {})", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("(async function f(x = (await) => {}) {})", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("(async function f(x = await /1/g) {})", "Cannot use 'await' within a parameter default _expression_.");
// AsyncFunctionDeclaration
shouldThrowSyntaxError("async function f() { var await; }", "Cannot use 'await' as a variable name in an async function.");
@@ -76,6 +79,9 @@
shouldThrowSyntaxError("async function f(...await) {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("async function f({await}) {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("async function f({isAsync: await}) {}", "Cannot use 'await' as a parameter name in an async function.");
+shouldThrowSyntaxError("async function f(x = await => {}) {}", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("async function f(x = (await) => {}) {}", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("async function f(x = await /1/g) {}", "Cannot use 'await' within a parameter default _expression_.");
// AsyncArrowFunction
shouldThrowSyntaxError("var f = async () => { var await; }", "Cannot use 'await' as a variable name in an async function.");
@@ -98,6 +104,7 @@
shouldThrowSyntaxError("var f = async () => { const {isAsync: await} = {}; }", "Cannot use 'await' as a lexical variable name in an async function.");
shouldThrowSyntaxError("var f = async () => { function await() {} }", "Cannot declare function named 'await' in an async function.");
shouldThrowSyntaxError("var f = async () => { async function await() {} }", "Cannot declare function named 'await' in an async function.");
+shouldThrowSyntaxError("var f = async await => {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var f = async (await) => {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var f = async ([await]) => {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var f = async ([...await]) => {}", "Cannot use 'await' as a parameter name in an async function.");
@@ -104,7 +111,9 @@
shouldThrowSyntaxError("var f = async (...await) => {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var f = async ({await}) => {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var f = async ({isAsync: await}) => {}", "Cannot use 'await' as a parameter name in an async function.");
-shouldThrowSyntaxError("var f = async await => {}", "Cannot use 'await' as a parameter name in an async function.");
+shouldThrowSyntaxError("var f = async (x = await => {}) => {}", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("var f = async (x = (await) => {}) => {}", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("var f = async (x = await /1/g) => {}", "Cannot use 'await' within a parameter default _expression_.");
// AsyncMethod
shouldThrowSyntaxError("var O = { async f() { var await; } }", "Cannot use 'await' as a variable name in an async function.");
@@ -133,6 +142,9 @@
shouldThrowSyntaxError("var O = { async f(...await) {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var O = { async f({await}) {}", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("var O = { async f({isAsync: await}) {}", "Cannot use 'await' as a parameter name in an async function.");
+shouldThrowSyntaxError("var O = { async f(x = await => {}) {} }", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("var O = { async f(x = (await) => {}) {} }", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("var O = { async f(x = await /1/g) {} }", "Cannot use 'await' within a parameter default _expression_.");
// AsyncFunction constructor
shouldThrowSyntaxError("AsyncFunction('var await;')", "Cannot use 'await' as a variable name in an async function.");
@@ -161,3 +173,6 @@
shouldThrowSyntaxError("AsyncFunction('...await', '')", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("AsyncFunction('{await}', '')", "Cannot use 'await' as a parameter name in an async function.");
shouldThrowSyntaxError("AsyncFunction('{isAsync: await}', '')", "Cannot use 'await' as a parameter name in an async function.");
+shouldThrowSyntaxError("AsyncFunction('x = await => {}', '')", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("AsyncFunction('x = (await) => {}', '')", "Cannot use 'await' within a parameter default _expression_.");
+shouldThrowSyntaxError("AsyncFunction('x = await /1/g', '')", "Cannot use 'await' within a parameter default _expression_.");
Modified: trunk/JSTests/stress/async-await-syntax.js (249924 => 249925)
--- trunk/JSTests/stress/async-await-syntax.js 2019-09-16 22:40:50 UTC (rev 249924)
+++ trunk/JSTests/stress/async-await-syntax.js 2019-09-16 22:56:08 UTC (rev 249925)
@@ -201,6 +201,11 @@
`var O = { *method(await) { return await; } };`,
`(function await() {})`,
+ `(function () { await => {}; })`,
+ `(function () { (await) => {}; })`,
+ `(function () { (x = await => {}) => {}; })`,
+ `(function () { (x = (await) => {}) => {}; })`,
+ `(function () { (x = await /1/g) => {}; })`,
];
for (let context of contextData) {
@@ -422,6 +427,9 @@
`var asyncArrow = async({ await = 1}) => {};`,
`var asyncArrow = async({ } = await) => 1;`,
`var asyncArrow = async({ } = await) => {};`,
+ `var asyncArrow = async() => { (x = await => {}) => {} };`,
+ `var asyncArrow = async() => { (x = (await) => {}) => {} };`,
+ `var asyncArrow = async() => { (x = await /1/g) => {} };`,
`({ async method(await) {} })`,
`({ async method(...await) {} })`,
Modified: trunk/JSTests/test262/expectations.yaml (249924 => 249925)
--- trunk/JSTests/test262/expectations.yaml 2019-09-16 22:40:50 UTC (rev 249924)
+++ trunk/JSTests/test262/expectations.yaml 2019-09-16 22:56:08 UTC (rev 249925)
@@ -2387,12 +2387,6 @@
test/language/expressions/assignment/fn-name-lhs-member.js:
default: 'Test262Error: Expected SameValue(«true», «false») to be true'
strict mode: 'Test262Error: Expected SameValue(«true», «false») to be true'
-test/language/expressions/async-arrow-function/await-as-param-ident-nested-arrow-parameter-position.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
-test/language/expressions/async-arrow-function/await-as-param-nested-arrow-body-position.js:
- default: 'Test262: This statement should not be evaluated.'
- strict mode: 'Test262: This statement should not be evaluated.'
test/language/expressions/call/eval-realm-indirect.js:
default: 'Test262Error: Expected SameValue(«inside», «outside») to be true'
test/language/expressions/call/eval-spread-empty-leading.js:
Modified: trunk/Source/_javascript_Core/ChangeLog (249924 => 249925)
--- trunk/Source/_javascript_Core/ChangeLog 2019-09-16 22:40:50 UTC (rev 249924)
+++ trunk/Source/_javascript_Core/ChangeLog 2019-09-16 22:56:08 UTC (rev 249925)
@@ -1,3 +1,22 @@
+2019-09-16 Ross Kirsling <ross.kirsl...@sony.com>
+
+ [JSC] Add missing syntax errors for await in function parameter default expressions
+ https://bugs.webkit.org/show_bug.cgi?id=201615
+
+ Reviewed by Darin Adler.
+
+ This patch rectifies two oversights:
+ 1. We were prohibiting `async function f(x = (await) => {}) {}` but not `async function f(x = await => {}) {}`
+ (and likewise for async arrow functions).
+ 2. We were not prohibiting `(x = await => {}) => {}` in an async context
+ (regardless of parentheses, but note that this one *only* applies to arrow functions).
+
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::isArrowFunctionParameters): Fix case (1).
+ (JSC::Parser<LexerType>::parseFunctionInfo): Fix case (2).
+ (JSC::Parser<LexerType>::parseAwaitExpression): Convert unfailing check into an ASSERT.
+ (JSC::Parser<LexerType>::parsePrimaryExpression): Adjust error message for case (2).
+
2019-09-16 Tadeu Zagallo <tzaga...@apple.com>
SamplingProfiler should hold API lock before reporting results
Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (249924 => 249925)
--- trunk/Source/_javascript_Core/parser/Parser.cpp 2019-09-16 22:40:50 UTC (rev 249924)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp 2019-09-16 22:56:08 UTC (rev 249925)
@@ -347,6 +347,7 @@
}
if (matchSpecIdentifier()) {
+ semanticFailIfTrue(!m_parserState.allowAwait && match(AWAIT), "Cannot use 'await' as a parameter name in an async function");
SavePoint saveArrowFunctionPoint = createSavePoint();
next();
bool isArrowFunction = match(ARROWFUNCTION);
@@ -2430,7 +2431,7 @@
// Parse formal parameters with [+Yield] parameterization, in order to ban YieldExpressions
// in ArrowFormalParameters, per ES6 #sec-arrow-function-definitions-static-semantics-early-errors.
Scope::MaybeParseAsGeneratorForScope parseAsGenerator(functionScope, parentScope->isGenerator());
- SetForScope<bool> overrideAllowAwait(m_parserState.allowAwait, !isAsyncFunctionParseMode(mode));
+ SetForScope<bool> overrideAllowAwait(m_parserState.allowAwait, !parentScope->isAsyncFunction() && !isAsyncFunctionParseMode(mode));
parseFunctionParameters(syntaxChecker, mode, functionInfo);
propagateError();
}
@@ -3830,7 +3831,7 @@
{
ASSERT(match(AWAIT));
ASSERT(currentScope()->isAsyncFunction());
- failIfTrue(m_parserState.functionParsePhase == FunctionParsePhase::Parameters, "Cannot use await _expression_ within parameters");
+ ASSERT(m_parserState.functionParsePhase != FunctionParsePhase::Parameters);
JSTokenLocation location(tokenLocation());
JSTextPosition divotStart = tokenStartPosition();
next();
@@ -4520,7 +4521,7 @@
}
case AWAIT:
if (m_parserState.functionParsePhase == FunctionParsePhase::Parameters)
- failIfFalse(m_parserState.allowAwait, "Cannot use await _expression_ within parameters");
+ semanticFailIfFalse(m_parserState.allowAwait, "Cannot use 'await' within a parameter default _expression_");
else if (currentFunctionScope()->isAsyncFunctionBoundary())
return parseAwaitExpression(context);