Title: [187014] trunk
Revision
187014
Author
[email protected]
Date
2015-07-19 12:31:36 -0700 (Sun, 19 Jul 2015)

Log Message

Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
https://bugs.webkit.org/show_bug.cgi?id=147090

Reviewed by Yusuke Suzuki.

Source/_javascript_Core:

ArrowFunction's have there ParserFunctionInfo "name" field to
be a non-null pointer. This is obviously allowed and valid except we
had a RELEASE_ASSERT that claimed otherwise. This is a mistake.

Note: ArrowFunction's will never actually have a function name;
there ParserFunctionInfo "name" field will be the empty string.
This is not be mistaken with the name field being a null pointer.

* parser/Parser.cpp:
(JSC::Parser<LexerType>::parseFunctionInfo):

LayoutTests:

* js/arrowfunction-strict-mode-expected.txt: Added.
* js/arrowfunction-strict-mode.html: Added.
* js/script-tests/arrowfunction-strict-mode.js: Added.
(foo):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (187013 => 187014)


--- trunk/LayoutTests/ChangeLog	2015-07-19 19:14:44 UTC (rev 187013)
+++ trunk/LayoutTests/ChangeLog	2015-07-19 19:31:36 UTC (rev 187014)
@@ -1,3 +1,15 @@
+2015-07-19  Saam barati  <[email protected]>
+
+        Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
+        https://bugs.webkit.org/show_bug.cgi?id=147090
+
+        Reviewed by Yusuke Suzuki.
+
+        * js/arrowfunction-strict-mode-expected.txt: Added.
+        * js/arrowfunction-strict-mode.html: Added.
+        * js/script-tests/arrowfunction-strict-mode.js: Added.
+        (foo):
+
 2015-07-18  Saam barati  <[email protected]>
 
         [ES6] Add support for block scope const

Added: trunk/LayoutTests/js/arrowfunction-strict-mode-expected.txt (0 => 187014)


--- trunk/LayoutTests/js/arrowfunction-strict-mode-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-strict-mode-expected.txt	2015-07-19 19:31:36 UTC (rev 187014)
@@ -0,0 +1,17 @@
+Tests for ES6 arrow function, make sure parsing is OK in strict mode.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS f1(10) is 10
+PASS f2(20) is 20
+PASS f3(10, 20) is 30
+PASS f4(20, 20) is 40
+PASS foo(x => x + 1) is 11
+PASS foo((x) => x + 1) is 11
+PASS foo(x => { return x + 1; }) is 11
+PASS foo((x) => { return x + 1; }) is 11
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/arrowfunction-strict-mode.html (0 => 187014)


--- trunk/LayoutTests/js/arrowfunction-strict-mode.html	                        (rev 0)
+++ trunk/LayoutTests/js/arrowfunction-strict-mode.html	2015-07-19 19:31:36 UTC (rev 187014)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/script-tests/arrowfunction-strict-mode.js (0 => 187014)


--- trunk/LayoutTests/js/script-tests/arrowfunction-strict-mode.js	                        (rev 0)
+++ trunk/LayoutTests/js/script-tests/arrowfunction-strict-mode.js	2015-07-19 19:31:36 UTC (rev 187014)
@@ -0,0 +1,24 @@
+"use strict";
+
+description('Tests for ES6 arrow function, make sure parsing is OK in strict mode.');
+
+var f1 = x => x;
+shouldBe("f1(10)", "10");
+
+var f2 = (x) => x;
+shouldBe("f2(20)", "20");
+
+var f3 = (x, y) => x + y;
+shouldBe("f3(10, 20)", "30");
+
+var f4 = (x, y) => { return x + y; };
+shouldBe("f4(20, 20)", "40");
+
+function foo(f) {
+    return f(10);
+}
+
+shouldBe("foo(x => x + 1)", "11");
+shouldBe("foo((x) => x + 1)", "11");
+shouldBe("foo(x => { return x + 1; })", "11");
+shouldBe("foo((x) => { return x + 1; })", "11");

Modified: trunk/Source/_javascript_Core/ChangeLog (187013 => 187014)


--- trunk/Source/_javascript_Core/ChangeLog	2015-07-19 19:14:44 UTC (rev 187013)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-07-19 19:31:36 UTC (rev 187014)
@@ -1,3 +1,21 @@
+2015-07-19  Saam barati  <[email protected]>
+
+        Parser::parseFunctionInfo hits RELEASE_ASSERT for Arrow Functions
+        https://bugs.webkit.org/show_bug.cgi?id=147090
+
+        Reviewed by Yusuke Suzuki.
+
+        ArrowFunction's have there ParserFunctionInfo "name" field to 
+        be a non-null pointer. This is obviously allowed and valid except we 
+        had a RELEASE_ASSERT that claimed otherwise. This is a mistake. 
+
+        Note: ArrowFunction's will never actually have a function name;
+        there ParserFunctionInfo "name" field will be the empty string. 
+        This is not be mistaken with the name field being a null pointer.
+
+        * parser/Parser.cpp:
+        (JSC::Parser<LexerType>::parseFunctionInfo):
+
 2015-07-18  Saam barati  <[email protected]>
 
         [ES6] Add support for block scope const

Modified: trunk/Source/_javascript_Core/parser/Parser.cpp (187013 => 187014)


--- trunk/Source/_javascript_Core/parser/Parser.cpp	2015-07-19 19:14:44 UTC (rev 187013)
+++ trunk/Source/_javascript_Core/parser/Parser.cpp	2015-07-19 19:31:36 UTC (rev 187014)
@@ -1714,7 +1714,7 @@
     failIfFalse(functionInfo.body, "Cannot parse the body of this ", stringForFunctionMode(mode));
     context.setEndOffset(functionInfo.body, m_lexer->currentOffset());
     if (functionScope->strictMode() && functionInfo.name) {
-        RELEASE_ASSERT(mode == NormalFunctionMode || mode == MethodMode);
+        RELEASE_ASSERT(mode == NormalFunctionMode || mode == MethodMode || mode == ArrowFunctionMode);
         semanticFailIfTrue(m_vm->propertyNames->arguments == *functionInfo.name, "'", functionInfo.name->impl(), "' is not a valid function name in strict mode");
         semanticFailIfTrue(m_vm->propertyNames->eval == *functionInfo.name, "'", functionInfo.name->impl(), "' is not a valid function name in strict mode");
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to