Bug 1520353 - Detect lexical variable earlier in BinAST. r=Yoric
authorTooru Fujisawa <arai_a@mac.com>
Thu, 17 Jan 2019 11:47:36 +0000
changeset 511366 c3da93a4af8ff7db326c1f9eed053f3645565836
parent 511365 3e943d2e39c9292cd0b5098a46116aaa9aaa1f3b
child 511367 cb3ca443d8c3f635764d2cc77f42aff6c3daecda
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersYoric
bugs1520353
milestone66.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 1520353 - Detect lexical variable earlier in BinAST. r=Yoric We're not handling lexical variable in BinAST parser for now, and it results in unhelpful error at the first reference. Detecting the lexical variable at declaration and throw more helpful error. Differential Revision: https://phabricator.services.mozilla.com/D16807
js/src/frontend/BinASTParser.cpp
js/src/frontend/BinASTParser.h
js/src/frontend/BinSource.yaml
js/src/frontend/BinToken.h
--- a/js/src/frontend/BinASTParser.cpp
+++ b/js/src/frontend/BinASTParser.cpp
@@ -1,12 +1,12 @@
 // This file was autogenerated by binjs_generate_spidermonkey,
 // please DO NOT EDIT BY HAND.
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: set ts=8 sts=2 et sw=2 tw=80:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // To generate this file, see the documentation in
 // js/src/frontend/binsource/README.md.
 
 #include "frontend/BinASTParser.h"
@@ -1513,17 +1513,22 @@ JS::Result<Ok> BinASTParser<Tok>::parseI
   MOZ_TRY(tokenizer_->checkFields(kind, fields, expected_fields));
 #endif  // defined(DEBUG)
   const bool allowDuplicateName = false;
 
   RootedAtom name(cx_);
   MOZ_TRY_VAR(name, tokenizer_->readIdentifierName());
 
   BINJS_MOZ_TRY_DECL(kind_, parseAssertedDeclaredKind());
-
+  if (kind_ == AssertedDeclaredKind::NonConstLexical) {
+    return raiseError("Let is not supported in this preview release");
+  }
+  if (kind_ == AssertedDeclaredKind::ConstLexical) {
+    return raiseError("Const is not supported in this preview release");
+  }
   BINJS_MOZ_TRY_DECL(isCaptured, tokenizer_->readBool());
   ParseContext::Scope* scope;
   DeclarationKind declKind;
   MOZ_TRY(getDeclaredScope(scopeKind, kind_, scope, declKind));
   MOZ_TRY(addScopeName(scopeKind, name, scope, declKind, isCaptured,
                        allowDuplicateName));
   auto result = Ok();
   return result;
--- a/js/src/frontend/BinASTParser.h
+++ b/js/src/frontend/BinASTParser.h
@@ -1,12 +1,12 @@
 // This file was autogenerated by binjs_generate_spidermonkey,
 // please DO NOT EDIT BY HAND.
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: set ts=8 sts=2 et sw=2 tw=80:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // To generate this file, see the documentation in
 // js/src/frontend/binsource/README.md.
 
 #ifndef frontend_BinASTParser_h
--- a/js/src/frontend/BinSource.yaml
+++ b/js/src/frontend/BinSource.yaml
@@ -395,16 +395,24 @@ AssertedBoundName:
                 MOZ_TRY(getBoundScope(scopeKind, scope, declKind));
     build: |
         MOZ_TRY(addScopeName(scopeKind, name, scope, declKind, isCaptured, allowDuplicateName));
         auto result = Ok();
 
 AssertedDeclaredName:
     inherits: AssertedBoundName
     fields:
+        kind:
+            after: |
+                if (kind_ == AssertedDeclaredKind::NonConstLexical) {
+                    return raiseError("Let is not supported in this preview release");
+                }
+                if (kind_ == AssertedDeclaredKind::ConstLexical) {
+                    return raiseError("Const is not supported in this preview release");
+                }
         isCaptured:
             after: |
                 ParseContext::Scope* scope;
                 DeclarationKind declKind;
                 MOZ_TRY(getDeclaredScope(scopeKind, kind_, scope, declKind));
 
 AssertedMaybePositionalParameterName:
     inherits: AssertedBoundName
--- a/js/src/frontend/BinToken.h
+++ b/js/src/frontend/BinToken.h
@@ -1,12 +1,12 @@
 // This file was autogenerated by binjs_generate_spidermonkey,
 // please DO NOT EDIT BY HAND.
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: set ts=8 sts=4 et sw=4 tw=99:
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: set ts=8 sts=2 et sw=2 tw=80:
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // To generate this file, see the documentation in
 // js/src/frontend/binsource/README.md.
 
 #ifndef frontend_BinToken_h