diff --git a/Libraries/LibJS/Bytecode/Generator.cpp b/Libraries/LibJS/Bytecode/Generator.cpp index 0f5c537cb1f..b219b7e5b20 100644 --- a/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Libraries/LibJS/Bytecode/Generator.cpp @@ -607,12 +607,18 @@ CodeGenerationErrorOr Generator::emit_super_refere auto actual_this = get_this(); Optional computed_property_value; + Optional property_key_id; if (expression.is_computed()) { // SuperProperty : super [ Expression ] // 3. Let propertyNameReference be ? Evaluation of Expression. // 4. Let propertyNameValue be ? GetValue(propertyNameReference). computed_property_value = TRY(expression.property().generate_bytecode(*this)).value(); + } else { + // SuperProperty : super . IdentifierName + // 3. Let propertyKey be the StringValue of IdentifierName. + auto const identifier_name = as(expression.property()).string(); + property_key_id = intern_identifier(identifier_name); } // 5/7. Return ? MakeSuperPropertyReference(actualThis, propertyKey, strict). @@ -628,6 +634,7 @@ CodeGenerationErrorOr Generator::emit_super_refere return ReferenceOperands { .base = base_value, .referenced_name = computed_property_value, + .referenced_identifier = property_key_id, .this_value = actual_this, }; } diff --git a/Libraries/LibJS/Tests/classes/class-inheritance.js b/Libraries/LibJS/Tests/classes/class-inheritance.js index a6de6f65f56..30f121ca87c 100644 --- a/Libraries/LibJS/Tests/classes/class-inheritance.js +++ b/Libraries/LibJS/Tests/classes/class-inheritance.js @@ -181,6 +181,16 @@ test("Issue #7044, super property access before super() call", () => { new Foo(); }); +test("super property load and store by identifier", () => { + class Foo { + constructor() { + super.bar += "1337"; + } + } + + new Foo(); +}); + test("Issue #8574, super property access before super() call", () => { var hit = false;