Ignore:
Timestamp:
Apr 12, 2016, 8:21:51 AM (9 years ago)
Author:
[email protected]
Message:

We incorrectly parse arrow function expressions
https://bugs.webkit.org/show_bug.cgi?id=156373

Reviewed by Mark Lam.

Source/JavaScriptCore:

This patch removes the notion of "isEndOfArrowFunction".
This was a very weird function and it was incorrect.
It checked that the arrow functions with concise body
grammar production "had a valid ending". "had a valid
ending" is in quotes because concise body arrow functions
have a valid ending as long as their body has a valid
assignment expression. I've removed all notion of this
function because it was wrong and was causing us
to throw syntax errors on valid programs.

  • parser/Lexer.cpp:

(JSC::Lexer<T>::nextTokenIsColon):
(JSC::Lexer<T>::lex):
(JSC::Lexer<T>::setTokenPosition): Deleted.

  • parser/Lexer.h:

(JSC::Lexer::setIsReparsingFunction):
(JSC::Lexer::isReparsingFunction):
(JSC::Lexer::lineNumber):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseInner):
(JSC::Parser<LexerType>::parseArrowFunctionSingleExpressionBodySourceElements):
(JSC::Parser<LexerType>::parseFunctionInfo):

  • parser/Parser.h:

(JSC::Parser::matchIdentifierOrKeyword):
(JSC::Parser::tokenStart):
(JSC::Parser::autoSemiColon):
(JSC::Parser::canRecurse):
(JSC::Parser::isEndOfArrowFunction): Deleted.
(JSC::Parser::setEndOfStatement): Deleted.

  • tests/stress/arrowfunction-others.js:

(testCase):
(simpleArrowFunction):
(truthy):
(falsey):

LayoutTests:

  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:

(catch):

File:
1 edited

Legend:

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

    r194981 r199352  
    17671767
    17681768template <typename T>
    1769 void Lexer<T>::setTokenPosition(JSToken* tokenRecord)
    1770 {
    1771     JSTokenData* tokenData = &tokenRecord->m_data;
    1772     tokenData->line = lineNumber();
    1773     tokenData->offset = currentOffset();
    1774     tokenData->lineStartOffset = currentLineStartOffset();
    1775     ASSERT(tokenData->offset >= tokenData->lineStartOffset);
    1776 }
    1777 
    1778 template <typename T>
    17791769JSTokenType Lexer<T>::lex(JSToken* tokenRecord, unsigned lexerFlags, bool strictMode)
    17801770{
Note: See TracChangeset for help on using the changeset viewer.