Bug 1185106 - Part 7.4: Fix property name parsing with async name. r=till
authorTooru Fujisawa <arai_a@mac.com>
Mon, 31 Oct 2016 05:33:11 +0900
changeset 320237 203903ea62ec88835f67ffaf938d39745461d486
parent 320236 f43c3c900fd72163fb8083601c2719a5c0246ed4
child 320238 0f59ff767344e7856642447f5e9a3679cc2fe4ab
push id20754
push usercbook@mozilla.com
push dateMon, 31 Oct 2016 15:58:35 +0000
treeherderfx-team@b1b66b1780c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1185106
milestone52.0a1
Bug 1185106 - Part 7.4: Fix property name parsing with async name. r=till
js/src/frontend/Parser.cpp
js/src/tests/ecma_7/AsyncFunctions/property.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -8762,17 +8762,17 @@ Parser<ParseHandler>::propertyName(Yield
         if (!tokenStream.getToken(&ltok, TokenStream::KeywordIsName))
             return null();
     }
 
     if (ltok == TOK_NAME && tokenStream.currentName() == context->names().async) {
         TokenKind tt;
         if (!tokenStream.getToken(&tt, TokenStream::KeywordIsName))
             return null();
-        if (tt != TOK_LP && tt != TOK_COLON) {
+        if (tt != TOK_LP && tt != TOK_COLON && tt != TOK_RC && tt != TOK_ASSIGN) {
             isAsync = true;
             ltok = tt;
         } else {
             tokenStream.ungetToken();
             tokenStream.addModifierException(TokenStream::NoneIsKeywordIsName);
         }
     }
 
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_7/AsyncFunctions/property.js
@@ -0,0 +1,39 @@
+var BUGNUMBER = 1185106;
+var summary = "async name token in property and object destructuring pattern";
+
+print(BUGNUMBER + ": " + summary);
+
+{
+  let a = { async: 10 };
+  assertEq(a.async, 10);
+}
+
+{
+  let a = { async() {} };
+  assertEq(a.async instanceof Function, true);
+  assertEq(a.async.name, "async");
+}
+
+{
+  let async = 11;
+  let a = { async };
+  assertEq(a.async, 11);
+}
+
+{
+  let { async } = { async: 12 };
+  assertEq(async, 12);
+}
+
+{
+  let { async = 13 } = {};
+  assertEq(async, 13);
+}
+
+{
+  let { async: a = 14 } = {};
+  assertEq(a, 14);
+}
+
+if (typeof reportCompare === "function")
+    reportCompare(true, true);