Ignore:
Timestamp:
Jun 16, 2014, 4:19:29 PM (11 years ago)
Author:
[email protected]
Message:

Parser statementDepth accounting needs to account for when a function body excludes its braces.
<https://webkit.org/b/133832>

Reviewed by Oliver Hunt.

Source/JavaScriptCore:
In some cases (e.g. when a Function object is instantiated from a string), the
function body source may not include its braces. The parser needs to account
for this when calculating its statementDepth.

  • bytecode/UnlinkedCodeBlock.cpp:

(JSC::generateFunctionCodeBlock):
(JSC::UnlinkedFunctionExecutable::codeBlockFor):

  • bytecode/UnlinkedCodeBlock.h:
  • parser/Parser.cpp:

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

  • Also fixed the error message for declaring nested functions in strict mode to be more accurate.
  • parser/Parser.h:

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

  • runtime/Executable.cpp:

(JSC::ScriptExecutable::newCodeBlockFor):

LayoutTests:

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
    • Added cases for declaring functions in strict mode.
    • Added caught error to the test result logging if it's not a SyntaxError. This helps catch the issue in this bug which was erroneously throwing RangeErrors.
File:
1 edited

Legend:

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

    r168107 r170034  
    11271127        return parseConstDeclaration(context);
    11281128    case FUNCTION:
    1129         failIfFalseIfStrict(m_statementDepth == 1, "Nested functions cannot be declared in strict mode");
     1129        failIfFalseIfStrict(m_statementDepth == 1, "Strict mode does not allow function declarations in a lexically nested statement");
    11301130        return parseFunctionDeclaration(context);
    11311131    case SEMICOLON: {
Note: See TracChangeset for help on using the changeset viewer.