Bug 1345162 - Fix identifier handling in Parser::standaloneFunction to follow new token kinds. r=till, a=gchang
authorTooru Fujisawa <arai_a@mac.com>
Wed, 08 Mar 2017 20:36:51 +0900
changeset 395077 dc2ab961df0d89039d1372c04cdbdf909321b6c3
parent 395076 13f6513650a20e0f5e0ea9a875629f2b00e611df
child 395078 da07ecdff44f03b1aecfc303b7c9d969374fae7e
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill, gchang
bugs1345162
milestone54.0a2
Bug 1345162 - Fix identifier handling in Parser::standaloneFunction to follow new token kinds. r=till, a=gchang
js/src/frontend/Parser.cpp
js/src/jit-test/tests/parser/standalone-function-name.js
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -2458,17 +2458,17 @@ Parser<FullParseHandler>::standaloneFunc
         return null();
     if (generatorKind == StarGenerator && asyncKind == SyncFunction) {
         MOZ_ASSERT(tt == TOK_MUL);
         if (!tokenStream.getToken(&tt))
             return null();
     }
 
     // Skip function name, if present.
-    if (tt == TOK_NAME || tt == TOK_YIELD) {
+    if (TokenKindIsPossibleIdentifierName(tt)) {
         MOZ_ASSERT(tokenStream.currentName() == fun->explicitName());
     } else {
         MOZ_ASSERT(fun->explicitName() == nullptr);
         tokenStream.ungetToken();
     }
 
     Node fn = handler.newFunctionStatement();
     if (!fn)
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/parser/standalone-function-name.js
@@ -0,0 +1,22 @@
+function test(name) {
+    eval(`
+function ${name}(stdlib, foreign, heap) {
+    "use asm";
+    var ffi = foreign.t;
+    return {};
+}
+${name}(15, 10);
+`);
+}
+
+test("as");
+test("async");
+test("await");
+test("each");
+test("from");
+test("get");
+test("let");
+test("of");
+test("set");
+test("static");
+test("target");