Changeset 270487 in webkit


Ignore:
Timestamp:
Dec 6, 2020 12:41:45 PM (20 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] get / set for object literal and class should not be escaped
https://bugs.webkit.org/show_bug.cgi?id=219576

Reviewed by Alexey Shvayka.

JSTests:

  • stress/escaped-getter-setter-in-class.js: Added.

(testSyntaxError):
(testSyntaxError.String.raw.A.prototype.u0067.u0065.u0074.m):
(testSyntaxError.String.raw.A):
(testSyntaxError.String.raw.A.prototype.u0073.u0065.u0074.m):

  • stress/escaped-getter-setter-in-object.js: Added.

(testSyntaxError):
(testSyntaxError.String.raw.u0067.u0065.u0074.m):
(testSyntaxError.String.raw.u0073.u0065.u0074.m):

  • test262/expectations.yaml:

Source/JavaScriptCore:

"get" and "set" for getter and setter should not be escaped one.
Terminal symbols of the lexical grammars are shown in fixed width font [1],
and are to appear in a script exactly as written.

[1]: https://tc39.es/ecma262/#sec-method-definitions

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseClass):
(JSC::Parser<LexerType>::parseProperty):

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r270481 r270487  
     12020-12-06  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] get / set for object literal and class should not be escaped
     4        https://bugs.webkit.org/show_bug.cgi?id=219576
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        * stress/escaped-getter-setter-in-class.js: Added.
     9        (testSyntaxError):
     10        (testSyntaxError.String.raw.A.prototype.u0067.u0065.u0074.m):
     11        (testSyntaxError.String.raw.A):
     12        (testSyntaxError.String.raw.A.prototype.u0073.u0065.u0074.m):
     13        * stress/escaped-getter-setter-in-object.js: Added.
     14        (testSyntaxError):
     15        (testSyntaxError.String.raw.u0067.u0065.u0074.m):
     16        (testSyntaxError.String.raw.u0073.u0065.u0074.m):
     17        * test262/expectations.yaml:
     18
    1192020-12-05  Yusuke Suzuki  <ysuzuki@apple.com>
    220
  • trunk/JSTests/test262/expectations.yaml

    r270481 r270487  
    17751775test/language/expressions/object/method-definition/async-gen-meth-eval-var-scope-syntax-err.js:
    17761776  default: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
    1777 test/language/expressions/object/method-definition/escaped-get-e.js:
    1778   default: 'Test262: This statement should not be evaluated.'
    1779   strict mode: 'Test262: This statement should not be evaluated.'
    1780 test/language/expressions/object/method-definition/escaped-get-g.js:
    1781   default: 'Test262: This statement should not be evaluated.'
    1782   strict mode: 'Test262: This statement should not be evaluated.'
    1783 test/language/expressions/object/method-definition/escaped-get-t.js:
    1784   default: 'Test262: This statement should not be evaluated.'
    1785   strict mode: 'Test262: This statement should not be evaluated.'
    1786 test/language/expressions/object/method-definition/escaped-get.js:
    1787   default: 'Test262: This statement should not be evaluated.'
    1788   strict mode: 'Test262: This statement should not be evaluated.'
    1789 test/language/expressions/object/method-definition/escaped-set-e.js:
    1790   default: 'Test262: This statement should not be evaluated.'
    1791   strict mode: 'Test262: This statement should not be evaluated.'
    1792 test/language/expressions/object/method-definition/escaped-set-s.js:
    1793   default: 'Test262: This statement should not be evaluated.'
    1794   strict mode: 'Test262: This statement should not be evaluated.'
    1795 test/language/expressions/object/method-definition/escaped-set-t.js:
    1796   default: 'Test262: This statement should not be evaluated.'
    1797   strict mode: 'Test262: This statement should not be evaluated.'
    1798 test/language/expressions/object/method-definition/escaped-set.js:
    1799   default: 'Test262: This statement should not be evaluated.'
    1800   strict mode: 'Test262: This statement should not be evaluated.'
    18011777test/language/expressions/object/method-definition/forbidden-ext/b2/gen-meth-forbidden-ext-indirect-access-own-prop-caller-get.js:
    18021778  default: 'TypeError: Function.caller used to retrieve generator body'
  • trunk/Source/JavaScriptCore/ChangeLog

    r270481 r270487  
     12020-12-06  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] get / set for object literal and class should not be escaped
     4        https://bugs.webkit.org/show_bug.cgi?id=219576
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        "get" and "set" for getter and setter should not be escaped one.
     9        Terminal symbols of the lexical grammars are shown in fixed width font [1],
     10        and are to appear in a script exactly as written.
     11
     12        [1]: https://tc39.es/ecma262/#sec-method-definitions
     13
     14        * parser/Parser.cpp:
     15        (JSC::Parser<LexerType>::parseClass):
     16        (JSC::Parser<LexerType>::parseProperty):
     17
    1182020-12-05  Yusuke Suzuki  <ysuzuki@apple.com>
    219
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r270481 r270487  
    29492949            }
    29502950            FALLTHROUGH;
    2951         case AWAIT:
     2951        case AWAIT: {
    29522952            ident = m_token.m_data.ident;
     2953            bool escaped = m_token.m_data.escaped;
    29532954            ASSERT(ident);
    29542955            next();
    2955             if (parseMode == SourceParseMode::MethodMode && (matchIdentifierOrKeyword() || match(STRING) || match(DOUBLE) || match(INTEGER) || match(BIGINT) || match(OPENBRACKET))) {
     2956            if (parseMode == SourceParseMode::MethodMode && !escaped && (matchIdentifierOrKeyword() || match(STRING) || match(DOUBLE) || match(INTEGER) || match(BIGINT) || match(OPENBRACKET))) {
    29562957                isGetter = *ident == propertyNames.get;
    29572958                isSetter = *ident == propertyNames.set;
    29582959            }
    29592960            break;
     2961        }
    29602962        case DOUBLE:
    29612963        case INTEGER:
     
    42134215namedProperty:
    42144216        const Identifier* ident = m_token.m_data.ident;
     4217        bool escaped = m_token.m_data.escaped;
    42154218        unsigned getterOrSetterStartOffset = tokenStart();
    42164219        JSToken identToken = m_token;
    42174220
    4218         if (wasIdent && !isGeneratorMethodParseMode(parseMode) && (*ident == m_vm.propertyNames->get || *ident == m_vm.propertyNames->set))
     4221        if (wasIdent && !isGeneratorMethodParseMode(parseMode) && (!escaped && (*ident == m_vm.propertyNames->get || *ident == m_vm.propertyNames->set)))
    42194222            nextExpectIdentifier(LexerFlags::IgnoreReservedWords);
    42204223        else
     
    42534256            classifyExpressionError(ErrorIndicatesPattern);
    42544257
    4255         PropertyNode::Type type;
    4256         if (*ident == m_vm.propertyNames->get)
    4257             type = PropertyNode::Getter;
    4258         else if (*ident == m_vm.propertyNames->set)
    4259             type = PropertyNode::Setter;
    4260         else
     4258        Optional<PropertyNode::Type> type;
     4259        if (!escaped) {
     4260            if (*ident == m_vm.propertyNames->get)
     4261                type = PropertyNode::Getter;
     4262            else if (*ident == m_vm.propertyNames->set)
     4263                type = PropertyNode::Setter;
     4264        }
     4265        if (!type)
    42614266            failWithMessage("Expected a ':' following the property name '", ident->impl(), "'");
    4262         return parseGetterSetter(context, type, getterOrSetterStartOffset, ConstructorKind::None, ClassElementTag::No);
     4267        return parseGetterSetter(context, type.value(), getterOrSetterStartOffset, ConstructorKind::None, ClassElementTag::No);
    42634268    }
    42644269    case DOUBLE:
Note: See TracChangeset for help on using the changeset viewer.