Changeset 217578 in webkit


Ignore:
Timestamp:
May 30, 2017 2:35:49 PM (7 years ago)
Author:
gskachkov@gmail.com
Message:

Prevent async methods named 'function' in Object literal
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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r217577 r217578  
     12017-05-30  Oleksandr Skachkov  <gskachkov@gmail.com>
     2
     3        Prevent async methods named 'function' in Object literal
     4        https://bugs.webkit.org/show_bug.cgi?id=172660
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/async-await-syntax.js:
     9        (testTopLevelAsyncAwaitSyntaxSloppyMode.testSyntaxError):
     10
    1112017-05-30  Oleksandr Skachkov  <gskachkov@gmail.com>
    212
  • trunk/JSTests/stress/async-await-syntax.js

    r217478 r217578  
    174174    testSyntaxError(`var O = { async asyncGeneratorMethod*() {} };`);
    175175
     176    testSyntaxError(`var O = { async function() {} };`);
     177
    176178    testSyntaxError(`var asyncFn = async function(x = await 1) { return x; }`);
    177179    testSyntaxError(`async function f(x = await 1) { return x; }`);
     
    253255    testSyntaxError(`"use strict"; var O = { async asyncGeneratorMethod*() {} };`);
    254256
     257    testSyntaxError(`"use strict"; var O = { async function() {} };`);
     258
    255259    testSyntaxError(`"use strict"; var asyncFn = async function(x = await 1) { return x; }`);
    256260    testSyntaxError(`"use strict"; async function f(x = await 1) { return x; }`);
  • trunk/Source/JavaScriptCore/ChangeLog

    r217577 r217578  
     12017-05-30  Oleksandr Skachkov  <gskachkov@gmail.com>
     2
     3        Prevent async methods named 'function' in Object literal
     4        https://bugs.webkit.org/show_bug.cgi?id=172660
     5
     6        Reviewed by Saam Barati.
     7
     8        Prevent async method named 'function' in object.
     9        https://github.com/tc39/ecma262/pull/884
     10
     11        * parser/Parser.cpp:
     12        (JSC::Parser<LexerType>::parsePropertyMethod):
     13
    1142017-05-30  Oleksandr Skachkov  <gskachkov@gmail.com>
    215
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r217478 r217578  
    38093809    ParserFunctionInfo<TreeBuilder> methodInfo;
    38103810    methodInfo.name = methodName;
     3811    semanticFailIfTrue(isAsyncMethod && *methodName == m_vm->propertyNames->functionKeyword, "Cannot declare an async method named 'function'");
    38113812    SourceParseMode parseMode = isGenerator ? SourceParseMode::GeneratorWrapperMethodMode : isAsyncMethod ? SourceParseMode::AsyncMethodMode : SourceParseMode::MethodMode;
    38123813    failIfFalse((parseFunctionInfo(context, FunctionNameRequirements::Unnamed, parseMode, false, ConstructorKind::None, SuperBinding::Needed, methodStart, methodInfo, FunctionDefinitionType::Method)), "Cannot parse this method");
Note: See TracChangeset for help on using the changeset viewer.