Skip to content
Permalink
Browse files
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:

Canonical link: https://commits.webkit.org/60507@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69941 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
ojhunt committed Oct 18, 2010
1 parent ce9753d commit 45a49f726057291a6e2d6b137dc9e7766d712e3f
@@ -1,3 +1,15 @@
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.
@@ -1869,19 +1869,22 @@ template <class TreeBuilder> TreeExpression JSParser::parseUnaryExpression(TreeB
int subExprStart = tokenStart();
TreeExpression expr = parseMemberExpression(context);
failIfFalse(expr);
bool isEval = false;
bool isEvalOrArguments = false;
if (strictMode() && !m_syntaxAlreadyValidated) {
if (context.isResolve(expr))
isEval = m_globalData->propertyNames->eval == *m_lastIdentifier;
if (context.isResolve(expr)) {
isEvalOrArguments = m_globalData->propertyNames->eval == *m_lastIdentifier;
if (!isEvalOrArguments && currentScope()->isFunction())
isEvalOrArguments = m_globalData->propertyNames->arguments == *m_lastIdentifier;
}
}
failIfTrueIfStrict(isEval && modifiesExpr);
failIfTrueIfStrict(isEvalOrArguments && modifiesExpr);
switch (m_token.m_type) {
case PLUSPLUS:
m_nonTrivialExpressionCount++;
m_nonLHSCount++;
expr = context.makePostfixNode(expr, OpPlusPlus, subExprStart, lastTokenEnd(), tokenEnd());
m_assignmentCount++;
failIfTrueIfStrict(isEval);
failIfTrueIfStrict(isEvalOrArguments);
failIfTrueIfStrict(requiresLExpr);
next();
break;
@@ -1890,7 +1893,7 @@ template <class TreeBuilder> TreeExpression JSParser::parseUnaryExpression(TreeB
m_nonLHSCount++;
expr = context.makePostfixNode(expr, OpMinusMinus, subExprStart, lastTokenEnd(), tokenEnd());
m_assignmentCount++;
failIfTrueIfStrict(isEval);
failIfTrueIfStrict(isEvalOrArguments);
failIfTrueIfStrict(requiresLExpr);
next();
break;
@@ -1,3 +1,16 @@
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:

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

Reviewed by Sam Weinig.
@@ -61,6 +61,19 @@ PASS 'use strict'; ++eval threw exception SyntaxError: Parse error.
PASS 'use strict'; eval++ threw exception SyntaxError: Parse error.
PASS 'use strict'; --eval threw exception SyntaxError: Parse error.
PASS 'use strict'; eval-- threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { ++arguments } threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { arguments++ } threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { --arguments } threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { arguments-- } threw exception SyntaxError: Parse error.
PASS global.eval('"use strict"; if (0) ++arguments; true;') is true
PASS 'use strict'; ++(1, eval) threw exception ReferenceError: Prefix ++ operator applied to value that is not a reference..
PASS 'use strict'; (1, eval)++ threw exception ReferenceError: Postfix ++ operator applied to value that is not a reference..
PASS 'use strict'; --(1, eval) threw exception ReferenceError: Prefix -- operator applied to value that is not a reference..
PASS 'use strict'; (1, eval)-- threw exception ReferenceError: Postfix -- operator applied to value that is not a reference..
PASS 'use strict'; function f() { ++(1, arguments) } threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { (1, arguments)++ } threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { --(1, arguments) } threw exception SyntaxError: Parse error.
PASS 'use strict'; function f() { (1, arguments)-- } threw exception SyntaxError: Parse error.
PASS 'use strict'; if (0) delete +a.b threw exception SyntaxError: Parse error.
PASS 'use strict'; if (0) delete ++a.b threw exception SyntaxError: Parse error.
PASS 'use strict'; if (0) delete void a.b threw exception SyntaxError: Parse error.
@@ -73,6 +73,20 @@ shouldThrow("'use strict'; ++eval");
shouldThrow("'use strict'; eval++");
shouldThrow("'use strict'; --eval");
shouldThrow("'use strict'; eval--");
shouldThrow("'use strict'; function f() { ++arguments }");
shouldThrow("'use strict'; function f() { arguments++ }");
shouldThrow("'use strict'; function f() { --arguments }");
shouldThrow("'use strict'; function f() { arguments-- }");
var global = this;
shouldBeTrue("global.eval('\"use strict\"; if (0) ++arguments; true;')");
shouldThrow("'use strict'; ++(1, eval)");
shouldThrow("'use strict'; (1, eval)++");
shouldThrow("'use strict'; --(1, eval)");
shouldThrow("'use strict'; (1, eval)--");
shouldThrow("'use strict'; function f() { ++(1, arguments) }");
shouldThrow("'use strict'; function f() { (1, arguments)++ }");
shouldThrow("'use strict'; function f() { --(1, arguments) }");
shouldThrow("'use strict'; function f() { (1, arguments)-- }");
shouldThrow("'use strict'; if (0) delete +a.b");
shouldThrow("'use strict'; if (0) delete ++a.b");
shouldThrow("'use strict'; if (0) delete void a.b");

0 comments on commit 45a49f7

Please sign in to comment.