2010-07-08 Oliver Hunt <oliver@apple.com>
authoroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jul 2010 23:22:21 +0000 (23:22 +0000)
committeroliver@apple.com <oliver@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 8 Jul 2010 23:22:21 +0000 (23:22 +0000)
        Reviewed by Gavin Barraclough.

        JavaScript parser violates ECMA automatic semicolon insertion rule
        https://bugs.webkit.org/show_bug.cgi?id=41844

        Remove (very) old and bogus logic that automatically inserted a semicolon
        at the end of a script's source.

        * parser/Lexer.cpp:
        (JSC::Lexer::lex):
2010-07-08  Oliver Hunt  <oliver@apple.com>

        Reviewed by Gavin Barraclough.

        JavaScript parser violates ECMA automatic semicolon insertion rule
        https://bugs.webkit.org/show_bug.cgi?id=41844

        Add testcase to ensure that we don't automatically insert a semicolon
        at the end of a script.

        * fast/js/no-semi-insertion-at-end-of-script-expected.txt: Added.
        * fast/js/no-semi-insertion-at-end-of-script.html: Added.
        * fast/js/script-tests/no-semi-insertion-at-end-of-script.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@62862 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JavaScriptCore/ChangeLog
JavaScriptCore/parser/Lexer.cpp
LayoutTests/ChangeLog
LayoutTests/fast/js/no-semi-insertion-at-end-of-script-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/no-semi-insertion-at-end-of-script.html [new file with mode: 0644]
LayoutTests/fast/js/script-tests/no-semi-insertion-at-end-of-script.js [new file with mode: 0644]

index 65c9242..3a466eb 100644 (file)
@@ -1,5 +1,18 @@
 2010-07-08  Oliver Hunt  <oliver@apple.com>
 
+        Reviewed by Gavin Barraclough.
+
+        JavaScript parser violates ECMA automatic semicolon insertion rule
+        https://bugs.webkit.org/show_bug.cgi?id=41844
+
+        Remove (very) old and bogus logic that automatically inserted a semicolon
+        at the end of a script's source.
+
+        * parser/Lexer.cpp:
+        (JSC::Lexer::lex):
+
+2010-07-08  Oliver Hunt  <oliver@apple.com>
+
         Reviewed by Anders Carlson.
 
         Tidy up the lexer
index 23e4f12..0cac785 100644 (file)
@@ -480,13 +480,8 @@ start:
 
     int startOffset = currentOffset();
 
-    if (UNLIKELY(m_current == -1)) {
-        if (!m_terminator && !m_delimited && !m_isReparsing) {
-            // automatic semicolon insertion if program incomplete
-            goto doneSemicolon;
-        }
+    if (UNLIKELY(m_current == -1))
         return 0;
-    }
 
     m_delimited = false;
 
index ab17fbd..8fb4070 100644 (file)
 
         Reviewed by Gavin Barraclough.
 
+        JavaScript parser violates ECMA automatic semicolon insertion rule
+        https://bugs.webkit.org/show_bug.cgi?id=41844
+
+        Add testcase to ensure that we don't automatically insert a semicolon
+        at the end of a script.
+
+        * fast/js/no-semi-insertion-at-end-of-script-expected.txt: Added.
+        * fast/js/no-semi-insertion-at-end-of-script.html: Added.
+        * fast/js/script-tests/no-semi-insertion-at-end-of-script.js: Added.
+
+2010-07-08  Oliver Hunt  <oliver@apple.com>
+
+        Reviewed by Gavin Barraclough.
+
         Make object-literal parsing conformant with the spec.
         https://bugs.webkit.org/show_bug.cgi?id=41892
 
diff --git a/LayoutTests/fast/js/no-semi-insertion-at-end-of-script-expected.txt b/LayoutTests/fast/js/no-semi-insertion-at-end-of-script-expected.txt
new file mode 100644 (file)
index 0000000..99cd878
--- /dev/null
@@ -0,0 +1,11 @@
+Test to make sure we don't automatically insert semicolons at the end of a script.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS if (0) threw exception SyntaxError: Parse error.
+PASS eval('if (0)') threw exception SyntaxError: Parse error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/no-semi-insertion-at-end-of-script.html b/LayoutTests/fast/js/no-semi-insertion-at-end-of-script.html
new file mode 100644 (file)
index 0000000..f9be5a3
--- /dev/null
@@ -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/no-semi-insertion-at-end-of-script.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/script-tests/no-semi-insertion-at-end-of-script.js b/LayoutTests/fast/js/script-tests/no-semi-insertion-at-end-of-script.js
new file mode 100644 (file)
index 0000000..3ff9fe3
--- /dev/null
@@ -0,0 +1,6 @@
+description("Test to make sure we don't automatically insert semicolons at the end of a script.");
+
+shouldThrow("if (0)");
+shouldThrow("eval('if (0)')");
+
+var successfullyParsed = true;