Ignore:
Timestamp:
Oct 15, 2010, 6:50:16 PM (15 years ago)
Author:
[email protected]
Message:

2010-10-15 Oliver Hunt <[email protected]>

Reviewed by Sam Weinig.

Automatic Semicolon Insertion incorrectly inserts semicolon after break, continue, and return followed by a newline
https://bugs.webkit.org/show_bug.cgi?id=47762

The old YACC parser depended on the lexer for some classes of semicolon insertion.
The new parser handles ASI entirely on its own so when the lexer inserts a semicolon
on its own the net result is a spurious semicolon in the input stream. This can result
in incorrect parsing in some cases:

if (0)

break

;else {}

Would result in a parse failure as the output from the lexer is essentially

if (0)

break

;;else

So the second semicolon is interpreted as a empty statement, which terminates the if,
making the else an error.

  • parser/JSParser.cpp: (JSC::JSParser::parseThrowStatement): Parsing of throw statement was wrong, and only worked due to the weird behaviour in the lexer
  • parser/Lexer.cpp: (JSC::Lexer::lex): Remove bogus semicolon insertion from the newline handling

2010-10-15 Oliver Hunt <[email protected]>

Reviewed by Sam Weinig.

ASI incorrectly inserts semicolon after break, continue, and return followed by a newline
https://bugs.webkit.org/show_bug.cgi?id=47762

tests for correct ASI following break, continue, and return

  • fast/js/break-ASI-expected.txt: Added.
  • fast/js/break-ASI.html: Added.
  • fast/js/script-tests/break-ASI.js: Added.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/parser/JSParser.cpp

    r69516 r69906  
    902902    int startLine = tokenLine();
    903903    next();
     904   
     905    failIfTrue(autoSemiColon());
    904906
    905907    TreeExpression expr = parseExpression(context);
     
    907909    int eEnd = lastTokenEnd();
    908910    int endLine = tokenLine();
    909     failIfFalse(autoSemiColon());
    910911
    911912    return context.createThrowStatement(expr, eStart, eEnd, startLine, endLine);
Note: See TracChangeset for help on using the changeset viewer.