Ignore:
Timestamp:
Jan 16, 2011, 3:54:40 PM (14 years ago)
Author:
[email protected]
Message:

2011-01-16 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

Strict mode restrictions on arguments and eval usage aren't complete
https://bugs.webkit.org/show_bug.cgi?id=52528

Add a helper function to aid parse failure tests by testing both direct
eval/global code, and nested code (so that we test the syntax checker
mode as well)

  • fast/js/basic-strict-mode-expected.txt:
  • fast/js/script-tests/basic-strict-mode.js: (shouldBeSyntaxError):

2011-01-16 Oliver Hunt <[email protected]>

Reviewed by Geoffrey Garen.

Strict mode restrictions on arguments and eval usage aren't complete
https://bugs.webkit.org/show_bug.cgi?id=52528

Fix a few bugs in strict mode where we incorrect allow mutation of
arguments and eval in the parser.

Alas the "optimisation" used by the syntax checker for validating
binary and unary expressions was too aggressive: we do actually need
a stack for operations and operands although it needn't be as complete
as that used for the full AST builder.

Also disallow assignment to arguments in all cases as allowing arguments
to be assignable is always an error in strict mode, regardless of context.

  • parser/ASTBuilder.h: (JSC::ASTBuilder::BinaryExprContext::BinaryExprContext): (JSC::ASTBuilder::UnaryExprContext::UnaryExprContext):
  • parser/JSParser.cpp: (JSC::JSParser::parseAssignmentExpression): (JSC::JSParser::parseBinaryExpression): (JSC::JSParser::parseUnaryExpression):
  • parser/SyntaxChecker.h: (JSC::SyntaxChecker::BinaryExprContext::BinaryExprContext): (JSC::SyntaxChecker::BinaryExprContext::~BinaryExprContext): (JSC::SyntaxChecker::UnaryExprContext::UnaryExprContext): (JSC::SyntaxChecker::UnaryExprContext::~UnaryExprContext): (JSC::SyntaxChecker::appendBinaryExpressionInfo): (JSC::SyntaxChecker::operatorStackPop):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r75408 r75896  
    8181        m_scopes.append(Scope(globalData));
    8282    }
     83   
     84    struct BinaryExprContext {
     85        BinaryExprContext(ASTBuilder&) {}
     86    };
     87    struct UnaryExprContext {
     88        UnaryExprContext(ASTBuilder&) {}
     89    };
    8390
    8491    typedef SyntaxChecker FunctionBodyBuilder;
Note: See TracChangeset for help on using the changeset viewer.