Changeset 69941 in webkit


Ignore:
Timestamp:
Oct 17, 2010 10:42:26 PM (14 years ago)
Author:
oliver@apple.com
Message:

2010-10-17 Oliver Hunt <oliver@apple.com>

Reviewed by Sam Weinig.

Strict mode: arguments is not valid as the base expression for pre- or post-fix expressions
https://bugs.webkit.org/show_bug.cgi?id=47791

Simple fix, check for arguments in addition to eval.

  • parser/JSParser.cpp: (JSC::JSParser::parseUnaryExpression):

2010-10-17 Oliver Hunt <oliver@apple.com>

Reviewed by Sam Weinig.

Strict mode: arguments is not valid as the base expression for pre- or post-fix expressions
https://bugs.webkit.org/show_bug.cgi?id=47791

Add arguments tests, and make pre-/post-fix expression tests cover another case I was
needlessly worried about.

  • fast/js/basic-strict-mode-expected.txt:
  • fast/js/script-tests/basic-strict-mode.js:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r69940 r69941  
     12010-10-17  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Strict mode: arguments is not valid as the base expression for pre- or post-fix expressions
     6        https://bugs.webkit.org/show_bug.cgi?id=47791
     7
     8        Simple fix, check for arguments in addition to eval.
     9
     10        * parser/JSParser.cpp:
     11        (JSC::JSParser::parseUnaryExpression):
     12
    1132010-10-17  Oliver Hunt  <oliver@apple.com>
    214
  • trunk/JavaScriptCore/parser/JSParser.cpp

    r69940 r69941  
    18701870    TreeExpression expr = parseMemberExpression(context);
    18711871    failIfFalse(expr);
    1872     bool isEval = false;
     1872    bool isEvalOrArguments = false;
    18731873    if (strictMode() && !m_syntaxAlreadyValidated) {
    1874         if (context.isResolve(expr))
    1875             isEval = m_globalData->propertyNames->eval == *m_lastIdentifier;
    1876     }
    1877     failIfTrueIfStrict(isEval && modifiesExpr);
     1874        if (context.isResolve(expr)) {
     1875            isEvalOrArguments = m_globalData->propertyNames->eval == *m_lastIdentifier;
     1876            if (!isEvalOrArguments && currentScope()->isFunction())
     1877                isEvalOrArguments = m_globalData->propertyNames->arguments == *m_lastIdentifier;
     1878        }
     1879    }
     1880    failIfTrueIfStrict(isEvalOrArguments && modifiesExpr);
    18781881    switch (m_token.m_type) {
    18791882    case PLUSPLUS:
     
    18821885        expr = context.makePostfixNode(expr, OpPlusPlus, subExprStart, lastTokenEnd(), tokenEnd());
    18831886        m_assignmentCount++;
    1884         failIfTrueIfStrict(isEval);
     1887        failIfTrueIfStrict(isEvalOrArguments);
    18851888        failIfTrueIfStrict(requiresLExpr);
    18861889        next();
     
    18911894        expr = context.makePostfixNode(expr, OpMinusMinus, subExprStart, lastTokenEnd(), tokenEnd());
    18921895        m_assignmentCount++;
    1893         failIfTrueIfStrict(isEval);
     1896        failIfTrueIfStrict(isEvalOrArguments);
    18941897        failIfTrueIfStrict(requiresLExpr);
    18951898        next();
  • trunk/LayoutTests/ChangeLog

    r69940 r69941  
     12010-10-17  Oliver Hunt  <oliver@apple.com>
     2
     3        Reviewed by Sam Weinig.
     4
     5        Strict mode: arguments is not valid as the base expression for pre- or post-fix expressions
     6        https://bugs.webkit.org/show_bug.cgi?id=47791
     7
     8        Add arguments tests, and make pre-/post-fix expression tests cover another case I was
     9        needlessly worried about.
     10
     11        * fast/js/basic-strict-mode-expected.txt:
     12        * fast/js/script-tests/basic-strict-mode.js:
     13
    1142010-10-17  Oliver Hunt  <oliver@apple.com>
    215
  • trunk/LayoutTests/fast/js/basic-strict-mode-expected.txt

    r69940 r69941  
    6262PASS 'use strict'; --eval threw exception SyntaxError: Parse error.
    6363PASS 'use strict'; eval-- threw exception SyntaxError: Parse error.
     64PASS 'use strict'; function f() { ++arguments } threw exception SyntaxError: Parse error.
     65PASS 'use strict'; function f() { arguments++ } threw exception SyntaxError: Parse error.
     66PASS 'use strict'; function f() { --arguments } threw exception SyntaxError: Parse error.
     67PASS 'use strict'; function f() { arguments-- } threw exception SyntaxError: Parse error.
     68PASS global.eval('"use strict"; if (0) ++arguments; true;') is true
     69PASS 'use strict'; ++(1, eval) threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
     70PASS 'use strict'; (1, eval)++ threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
     71PASS 'use strict'; --(1, eval) threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
     72PASS 'use strict'; (1, eval)-- threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
     73PASS 'use strict'; function f() { ++(1, arguments) } threw exception SyntaxError: Parse error.
     74PASS 'use strict'; function f() { (1, arguments)++ } threw exception SyntaxError: Parse error.
     75PASS 'use strict'; function f() { --(1, arguments) } threw exception SyntaxError: Parse error.
     76PASS 'use strict'; function f() { (1, arguments)-- } threw exception SyntaxError: Parse error.
    6477PASS 'use strict'; if (0) delete +a.b threw exception SyntaxError: Parse error.
    6578PASS 'use strict'; if (0) delete ++a.b threw exception SyntaxError: Parse error.
  • trunk/LayoutTests/fast/js/script-tests/basic-strict-mode.js

    r69940 r69941  
    7474shouldThrow("'use strict'; --eval");
    7575shouldThrow("'use strict'; eval--");
     76shouldThrow("'use strict'; function f() { ++arguments }");
     77shouldThrow("'use strict'; function f() { arguments++ }");
     78shouldThrow("'use strict'; function f() { --arguments }");
     79shouldThrow("'use strict'; function f() { arguments-- }");
     80var global = this;
     81shouldBeTrue("global.eval('\"use strict\"; if (0) ++arguments; true;')");
     82shouldThrow("'use strict'; ++(1, eval)");
     83shouldThrow("'use strict'; (1, eval)++");
     84shouldThrow("'use strict'; --(1, eval)");
     85shouldThrow("'use strict'; (1, eval)--");
     86shouldThrow("'use strict'; function f() { ++(1, arguments) }");
     87shouldThrow("'use strict'; function f() { (1, arguments)++ }");
     88shouldThrow("'use strict'; function f() { --(1, arguments) }");
     89shouldThrow("'use strict'; function f() { (1, arguments)-- }");
    7690shouldThrow("'use strict'; if (0) delete +a.b");
    7791shouldThrow("'use strict'; if (0) delete ++a.b");
Note: See TracChangeset for help on using the changeset viewer.