Bug 1530084 - Don't crash on unsupported syntax when fields are disabled. r=jorendorff
authorAshley Hauck <khyperia@mozilla.com>
Mon, 25 Feb 2019 22:10:17 +0000
changeset 518906 57f2a3550fafe52aeb94187337789cf354fd5e06
parent 518905 a716ff1b62ab72a859f1a016c6635919502d4abe
child 518907 b36c070f066b2d17c4b3d871cfac28e9c1961e31
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1530084
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1530084 - Don't crash on unsupported syntax when fields are disabled. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D20989
js/src/frontend/Parser.cpp
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -6856,16 +6856,22 @@ GeneralParser<ParseHandler, Unit>::class
     PropertyType propType;
     Node propName = propertyName(yieldHandling, PropertyNameInClass, declKind,
                                  classMembers, &propType, &propAtom);
     if (!propName) {
       return null();
     }
 
     if (propType == PropertyType::Field) {
+      // TODO(khyperia): Delete the two lines below once fields are fully
+      // supported in the backend. We can't fail in BytecodeCompiler because of
+      // lazy parsing.
+      errorAt(propNameOffset, JSMSG_FIELDS_NOT_SUPPORTED);
+      return null();
+
       if (isStatic) {
         errorAt(propNameOffset, JSMSG_BAD_METHOD_DEF);
         return null();
       }
       if (!tokenStream.getToken(&tt)) {
         return null();
       }
 
@@ -6888,21 +6894,17 @@ GeneralParser<ParseHandler, Unit>::class
         return null();
       }
 
       if (!handler_.addClassFieldDefinition(classMembers, propName,
                                             initializer)) {
         return null();
       }
 
-      // TODO(khyperia): Change the below to `continue;` once fields are
-      // fully supported in the backend. We can't fail in BytecodeCompiler
-      // because of lazy parsing.
-      errorAt(propNameOffset, JSMSG_FIELDS_NOT_SUPPORTED);
-      return null();
+      continue;
     }
 
     if (propType != PropertyType::Getter && propType != PropertyType::Setter &&
         propType != PropertyType::Method &&
         propType != PropertyType::GeneratorMethod &&
         propType != PropertyType::AsyncMethod &&
         propType != PropertyType::AsyncGeneratorMethod) {
       errorAt(propNameOffset, JSMSG_BAD_METHOD_DEF);