Title: [106297] trunk
Revision
106297
Author
[email protected]
Date
2012-01-30 15:59:20 -0800 (Mon, 30 Jan 2012)

Log Message

Unexpected syntax error
https://bugs.webkit.org/show_bug.cgi?id=77340

Reviewed by Gavin Barraclough.

Source/_javascript_Core:

Function calls and new expressions have the same semantics for
assignment, so should simply share their lhs handling.

* parser/Parser.cpp:
(JSC::::parseMemberExpression):

LayoutTests:

Add new tests for correct parsing of new expressions

* fast/js/parser-syntax-check-expected.txt:
* fast/js/script-tests/parser-syntax-check.js:
(runTest):
(invalid):

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106296 => 106297)


--- trunk/LayoutTests/ChangeLog	2012-01-30 23:56:00 UTC (rev 106296)
+++ trunk/LayoutTests/ChangeLog	2012-01-30 23:59:20 UTC (rev 106297)
@@ -1,3 +1,17 @@
+2012-01-30  Oliver Hunt  <[email protected]>
+
+        Unexpected syntax error
+        https://bugs.webkit.org/show_bug.cgi?id=77340
+
+        Reviewed by Gavin Barraclough.
+
+        Add new tests for correct parsing of new expressions
+
+        * fast/js/parser-syntax-check-expected.txt:
+        * fast/js/script-tests/parser-syntax-check.js:
+        (runTest):
+        (invalid):
+
 2012-01-30  Tony Chang  <[email protected]>
 
         css3/flexbox/cross-axis-scrollbar.html ref test fails on Windows Chromium bots

Modified: trunk/LayoutTests/fast/js/parser-syntax-check-expected.txt (106296 => 106297)


--- trunk/LayoutTests/fast/js/parser-syntax-check-expected.txt	2012-01-30 23:56:00 UTC (rev 106296)
+++ trunk/LayoutTests/fast/js/parser-syntax-check-expected.txt	2012-01-30 23:59:20 UTC (rev 106297)
@@ -567,6 +567,10 @@
 PASS Valid:   "function f() { if (0) obj.foo_;  }"
 PASS Valid:   "if (0) obj.foo\u03bb; "
 PASS Valid:   "function f() { if (0) obj.foo\u03bb;  }"
+PASS Valid:   "if (0) new a(b+c).d = 5"
+PASS Valid:   "function f() { if (0) new a(b+c).d = 5 }"
+PASS Valid:   "if (0) new a(b+c) = 5"
+PASS Valid:   "function f() { if (0) new a(b+c) = 5 }"
 PASS e.line is 1
 PASS foo is 'PASS'
 PASS bar is 'PASS'

Modified: trunk/LayoutTests/fast/js/script-tests/parser-syntax-check.js (106296 => 106297)


--- trunk/LayoutTests/fast/js/script-tests/parser-syntax-check.js	2012-01-30 23:56:00 UTC (rev 106296)
+++ trunk/LayoutTests/fast/js/script-tests/parser-syntax-check.js	2012-01-30 23:59:20 UTC (rev 106297)
@@ -2,7 +2,7 @@
 "This test checks that the following expressions or statements are valid ECMASCRIPT code or should throw parse error"
 );
 
-function runTest(_a, throws)
+function runTest(_a, errorType)
 {
     var success;
     if (typeof _a != "string")
@@ -13,16 +13,16 @@
     } catch (e) {
         success = !(e instanceof SyntaxError);
     }
-    if (throws == !success) {
-        if (throws)
+    if ((!!errorType) == !success) {
+        if (errorType)
             testPassed('Invalid: "' + _a + '"');
         else
             testPassed('Valid:   "' + _a + '"');
     } else {
-        if (throws)
-            testFailed('Invalid: "' + _a + '" should throw SyntaxError: Parse error');
+        if (errorType)
+            testFailed('Invalid: "' + _a + '" should throw ' + errorType.name);
         else
-            testFailed('Valid:   "' + _a + '" should NOT throw SyntaxError: Parse error');
+            testFailed('Valid:   "' + _a + '" should NOT throw ');
     }
 }
 
@@ -33,8 +33,9 @@
     runTest("function f() { " + _a + " }", false);
 }
 
-function invalid(_a)
+function invalid(_a, _type)
 {
+    _type = _type || SyntaxError;
     // Test both the grammar and the syntax checker
     runTest(_a, true);
     runTest("function f() { " + _a + " }", true);
@@ -360,6 +361,8 @@
 valid("if (0) obj.foo$; ")
 valid("if (0) obj.foo_; ")
 valid("if (0) obj.foo\\u03bb; ")
+valid("if (0) new a(b+c).d = 5");
+valid("if (0) new a(b+c) = 5");
 
 try { eval("a.b.c = {};"); } catch(e1) { e=e1; shouldBe("e.line", "1") }
 foo = 'FAIL';

Modified: trunk/Source/_javascript_Core/ChangeLog (106296 => 106297)


--- trunk/Source/_javascript_Core/ChangeLog	2012-01-30 23:56:00 UTC (rev 106296)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-01-30 23:59:20 UTC (rev 106297)
@@ -1,3 +1,16 @@
+2012-01-30  Oliver Hunt  <[email protected]>
+
+        Unexpected syntax error
+        https://bugs.webkit.org/show_bug.cgi?id=77340
+
+        Reviewed by Gavin Barraclough.
+
+        Function calls and new expressions have the same semantics for
+        assignment, so should simply share their lhs handling.
+
+        * parser/Parser.cpp:
+        (JSC::::parseMemberExpression):
+
 2012-01-30  Gavin Barraclough  <[email protected]>
 
         Unreviewed ARMv7 build fix.

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (106296 => 106297)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2012-01-30 23:56:00 UTC (rev 106296)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2012-01-30 23:59:20 UTC (rev 106297)
@@ -1512,23 +1512,20 @@
         }
         case OPENPAREN: {
             m_nonTrivialExpressionCount++;
+            int nonLHSCount = m_nonLHSCount;
             if (newCount) {
                 newCount--;
-                if (match(OPENPAREN)) {
-                    int exprEnd = lastTokenEnd();
-                    TreeArguments arguments = parseArguments(context);
-                    failIfFalse(arguments);
-                    base = context.createNewExpr(m_lexer->lastLineNumber(), base, arguments, start, exprEnd, lastTokenEnd());
-                } else
-                    base = context.createNewExpr(m_lexer->lastLineNumber(), base, start, lastTokenEnd());               
+                int exprEnd = lastTokenEnd();
+                TreeArguments arguments = parseArguments(context);
+                failIfFalse(arguments);
+                base = context.createNewExpr(m_lexer->lastLineNumber(), base, arguments, start, exprEnd, lastTokenEnd());           
             } else {
-                int nonLHSCount = m_nonLHSCount;
                 int expressionEnd = lastTokenEnd();
                 TreeArguments arguments = parseArguments(context);
                 failIfFalse(arguments);
                 base = context.makeFunctionCallNode(m_lexer->lastLineNumber(), base, arguments, expressionStart, expressionEnd, lastTokenEnd());
-                m_nonLHSCount = nonLHSCount;
             }
+            m_nonLHSCount = nonLHSCount;
             break;
         }
         case DOT: {
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to