https://bugs.webkit.org/show_bug.cgi?id=172660
Reviewed by Saam Barati.
JSTests:
* stress/async-await-syntax.js:
(testTopLevelAsyncAwaitSyntaxSloppyMode.testSyntaxError):
Source/JavaScriptCore:
Prevent async method named 'function' in object.
https://github.com/tc39/ecma262/pull/884
* parser/Parser.cpp:
(JSC::Parser<LexerType>::parsePropertyMethod):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217578
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
2017-05-30 Oleksandr Skachkov <gskachkov@gmail.com>
+ Prevent async methods named 'function' in Object literal
+ https://bugs.webkit.org/show_bug.cgi?id=172660
+
+ Reviewed by Saam Barati.
+
+ * stress/async-await-syntax.js:
+ (testTopLevelAsyncAwaitSyntaxSloppyMode.testSyntaxError):
+
+2017-05-30 Oleksandr Skachkov <gskachkov@gmail.com>
+
ASSERTION FAILED: generator.isConstructor() || generator.derivedContextType() == DerivedContextType::DerivedConstructorContext
https://bugs.webkit.org/show_bug.cgi?id=171274
testSyntaxError(`var O = { async *asyncGeneratorMethod() {} };`);
testSyntaxError(`var O = { async asyncGeneratorMethod*() {} };`);
+ testSyntaxError(`var O = { async function() {} };`);
+
testSyntaxError(`var asyncFn = async function(x = await 1) { return x; }`);
testSyntaxError(`async function f(x = await 1) { return x; }`);
testSyntaxError(`var f = async(x = await 1) => x;`);
testSyntaxError(`"use strict"; var O = { async *asyncGeneratorMethod() {} };`);
testSyntaxError(`"use strict"; var O = { async asyncGeneratorMethod*() {} };`);
+ testSyntaxError(`"use strict"; var O = { async function() {} };`);
+
testSyntaxError(`"use strict"; var asyncFn = async function(x = await 1) { return x; }`);
testSyntaxError(`"use strict"; async function f(x = await 1) { return x; }`);
testSyntaxError(`"use strict"; var f = async(x = await 1) => x;`);
2017-05-30 Oleksandr Skachkov <gskachkov@gmail.com>
+ Prevent async methods named 'function' in Object literal
+ https://bugs.webkit.org/show_bug.cgi?id=172660
+
+ Reviewed by Saam Barati.
+
+ Prevent async method named 'function' in object.
+ https://github.com/tc39/ecma262/pull/884
+
+ * parser/Parser.cpp:
+ (JSC::Parser<LexerType>::parsePropertyMethod):
+
+2017-05-30 Oleksandr Skachkov <gskachkov@gmail.com>
+
ASSERTION FAILED: generator.isConstructor() || generator.derivedContextType() == DerivedContextType::DerivedConstructorContext
https://bugs.webkit.org/show_bug.cgi?id=171274
unsigned methodStart = tokenStart();
ParserFunctionInfo<TreeBuilder> methodInfo;
methodInfo.name = methodName;
+ semanticFailIfTrue(isAsyncMethod && *methodName == m_vm->propertyNames->functionKeyword, "Cannot declare an async method named 'function'");
SourceParseMode parseMode = isGenerator ? SourceParseMode::GeneratorWrapperMethodMode : isAsyncMethod ? SourceParseMode::AsyncMethodMode : SourceParseMode::MethodMode;
failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, false, ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method)), "Cannot parse this method");
return context.createMethodDefinition(methodLocation, methodInfo);