Title: [271420] trunk
Revision
271420
Author
[email protected]
Date
2021-01-12 16:05:54 -0800 (Tue, 12 Jan 2021)

Log Message

[ESNext] super accesses broken on arrow functions defined as class field
https://bugs.webkit.org/show_bug.cgi?id=220558

Reviewed by Darin Adler.

JSTests:

* stress/class-field-arrow-function-using-super.js: Added.

Source/_javascript_Core:

We need to properly set `isClassContext` for class fields
initialization.

* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::generateUnlinkedFunctionCodeBlock):

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (271419 => 271420)


--- trunk/JSTests/ChangeLog	2021-01-12 23:13:15 UTC (rev 271419)
+++ trunk/JSTests/ChangeLog	2021-01-13 00:05:54 UTC (rev 271420)
@@ -1,3 +1,12 @@
+2021-01-12  Caio Lima  <[email protected]>
+
+        [ESNext] super accesses broken on arrow functions defined as class field
+        https://bugs.webkit.org/show_bug.cgi?id=220558
+
+        Reviewed by Darin Adler.
+
+        * stress/class-field-arrow-function-using-super.js: Added.
+
 2021-01-08  Alexey Shvayka  <[email protected]>
 
         Implement @copyDataProperties in C++ to optimize object rest / spread

Added: trunk/JSTests/stress/class-field-arrow-function-using-super.js (0 => 271420)


--- trunk/JSTests/stress/class-field-arrow-function-using-super.js	                        (rev 0)
+++ trunk/JSTests/stress/class-field-arrow-function-using-super.js	2021-01-13 00:05:54 UTC (rev 271420)
@@ -0,0 +1,15 @@
+function assert(actual, expected) {
+    if (actual !== expected)
+        throw Error("Expected: " + expected + " Actual: " + actual);
+}
+
+class C {
+    func = () => {
+        super.prop = "foo";
+        return this.prop;
+    };
+}
+
+let c = new C;
+assert(c.func(), "foo");
+

Modified: trunk/Source/_javascript_Core/ChangeLog (271419 => 271420)


--- trunk/Source/_javascript_Core/ChangeLog	2021-01-12 23:13:15 UTC (rev 271419)
+++ trunk/Source/_javascript_Core/ChangeLog	2021-01-13 00:05:54 UTC (rev 271420)
@@ -1,3 +1,16 @@
+2021-01-12  Caio Lima  <[email protected]>
+
+        [ESNext] super accesses broken on arrow functions defined as class field
+        https://bugs.webkit.org/show_bug.cgi?id=220558
+
+        Reviewed by Darin Adler.
+
+        We need to properly set `isClassContext` for class fields
+        initialization.
+
+        * bytecode/UnlinkedFunctionExecutable.cpp:
+        (JSC::generateUnlinkedFunctionCodeBlock):
+
 2021-01-12  Don Olmstead  <[email protected]>
 
         Non-unified build fixes mid January 2021 edition

Modified: trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp (271419 => 271420)


--- trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp	2021-01-12 23:13:15 UTC (rev 271419)
+++ trunk/Source/_javascript_Core/bytecode/UnlinkedFunctionExecutable.cpp	2021-01-13 00:05:54 UTC (rev 271420)
@@ -68,7 +68,7 @@
     function->finishParsing(executable->name(), executable->functionMode());
     executable->recordParse(function->features(), function->hasCapturedVariables());
 
-    bool isClassContext = executable->superBinding() == SuperBinding::Needed;
+    bool isClassContext = executable->superBinding() == SuperBinding::Needed || executable->parseMode() == SourceParseMode::ClassFieldInitializerMode;
 
     UnlinkedFunctionCodeBlock* result = UnlinkedFunctionCodeBlock::create(vm, FunctionCode, ExecutableInfo(function->usesEval(), kind == CodeForConstruct, functionKind == UnlinkedBuiltinFunction, executable->constructorKind(), scriptMode, executable->superBinding(), parseMode, executable->derivedContextType(), executable->needsClassFieldInitializer(), false, isClassContext, EvalContextType::FunctionEvalContext), codeGenerationMode);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to