Ignore:
Timestamp:
Aug 5, 2015, 9:01:00 PM (10 years ago)
Author:
[email protected]
Message:

[ES6] Class parser does not allow methods named set and get.
https://bugs.webkit.org/show_bug.cgi?id=147150

Reviewed by Oliver Hunt.

Source/JavaScriptCore:

The bug was caused by parseClass assuming identifiers "get" and "set" could only appear
as the leading token for getter and setter methods. Fixed the bug by generalizing the code
so that we only treat them as such when it's followed by another token that could be a method name.

  • parser/Parser.cpp:

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

LayoutTests:

Added a regression test and rebaselined a test.

  • js/class-syntax-method-names-expected.txt: Added.
  • js/class-syntax-method-names.html: Added.
  • js/class-syntax-semicolon-expected.txt: Rebaselined as the error message got improved.
  • js/script-tests/class-syntax-method-names.js: Added.
  • js/script-tests/class-syntax-semicolon.js:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r187890 r188018  
    19511951        case IDENT:
    19521952            ident = m_token.m_data.ident;
    1953             isGetter = *ident == propertyNames.get;
    1954             isSetter = *ident == propertyNames.set;
    19551953            ASSERT(ident);
     1954            next();
     1955            if (match(IDENT) || match(STRING) || match(DOUBLE) || match(INTEGER)) {
     1956                isGetter = *ident == propertyNames.get;
     1957                isSetter = *ident == propertyNames.set;
     1958            }
    19561959            break;
    19571960        case DOUBLE:
     
    19681971        const bool alwaysStrictInsideClass = true;
    19691972        if (isGetter || isSetter) {
    1970             nextExpectIdentifier(LexerFlagsIgnoreReservedWords);
    19711973            property = parseGetterSetter(context, alwaysStrictInsideClass, isGetter ? PropertyNode::Getter : PropertyNode::Setter, methodStart,
    19721974                ConstructorKind::None, SuperBinding::Needed);
Note: See TracChangeset for help on using the changeset viewer.