Bug 1540787 - Always declare .this in constructors. r=jorendorff
authorAshley Hauck <khyperia@mozilla.com>
Wed, 24 Apr 2019 18:50:37 +0000
changeset 530007 afb947a236befa6eb6f23783405bd9c334aa4129
parent 530006 a1ac474e747d1a96779e383a6bed943abfb85ce9
child 530008 c66792afc2c28ae0a555c73f4e34b87435f1f7b6
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorendorff
bugs1540787
milestone68.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 1540787 - Always declare .this in constructors. r=jorendorff Differential Revision: https://phabricator.services.mozilla.com/D27783
js/src/frontend/ParseContext.cpp
js/src/jit-test/tests/fields/bug1540787.js
--- a/js/src/frontend/ParseContext.cpp
+++ b/js/src/frontend/ParseContext.cpp
@@ -502,17 +502,18 @@ bool ParseContext::declareFunctionThis(c
   FunctionBox* funbox = functionBox();
   HandlePropertyName dotThis = sc()->cx_->names().dotThis;
 
   bool declareThis;
   if (canSkipLazyClosedOverBindings) {
     declareThis = funbox->function()->lazyScript()->hasThisBinding();
   } else {
     declareThis = hasUsedFunctionSpecialName(usedNames, dotThis) ||
-                  funbox->isDerivedClassConstructor();
+                  funbox->function()->kind() ==
+                      JSFunction::FunctionKind::ClassConstructor;
   }
 
   if (declareThis) {
     ParseContext::Scope& funScope = functionScope();
     AddDeclaredNamePtr p = funScope.lookupDeclaredNameForAdd(dotThis);
     MOZ_ASSERT(!p);
     if (!funScope.addDeclaredName(this, p, dotThis, DeclarationKind::Var,
                                   DeclaredNameInfo::npos)) {
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/fields/bug1540787.js
@@ -0,0 +1,6 @@
+// |jit-test| --enable-experimental-fields
+
+class C {
+    x = 1;
+    constructor() {};
+}