Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
2010-10-15 Oliver Hunt <oliver@apple.com>
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 <oliver@apple.com> 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. Canonical link: https://commits.webkit.org/60477@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69906 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
7 changed files
with
87 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
Test to make sure we don't incorrectly insert a semi colon after a break statement | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS do { if(0) break | ||
;else true; } while (0) is true | ||
PASS do { if(0) continue | ||
;else true; } while (0) is true | ||
PASS (function(){if (0) return | ||
;else return true;})() is true | ||
PASS if (0) throw | ||
'Shouldn't have parsed this.'; threw exception SyntaxError: Parse error. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="resources/js-test-style.css"> | ||
<script src="resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<p id="description"></p> | ||
<div id="console"></div> | ||
<script src="script-tests/break-ASI.js"></script> | ||
<script src="resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,8 @@ | ||
description("Test to make sure we don't incorrectly insert a semi colon after a break statement"); | ||
|
||
shouldBeTrue("do { if(0) break\n;else true; } while (0)") | ||
shouldBeTrue("do { if(0) continue\n;else true; } while (0)") | ||
shouldBeTrue("(function(){if (0) return\n;else return true;})()") | ||
shouldThrow("if (0) throw\n'Shouldn\'t have parsed this.';") | ||
|
||
var successfullyParsed = true; |