mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibJS: Fix bytecode generation for super property stores and loads
The new test case crashes during bytecode generation due to `emit_super_reference` not correctly generating the reference record for the property access.
This commit is contained in:
parent
778947213b
commit
356728b1e0
Notes:
github-actions[bot]
2025-02-15 12:01:01 +00:00
Author: https://github.com/ttrssreal Commit: https://github.com/LadybirdBrowser/ladybird/commit/356728b1e0c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3565 Reviewed-by: https://github.com/trflynn89
2 changed files with 17 additions and 0 deletions
|
@ -607,12 +607,18 @@ CodeGenerationErrorOr<Generator::ReferenceOperands> Generator::emit_super_refere
|
|||
auto actual_this = get_this();
|
||||
|
||||
Optional<ScopedOperand> computed_property_value;
|
||||
Optional<IdentifierTableIndex> 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<Identifier>(expression.property()).string();
|
||||
property_key_id = intern_identifier(identifier_name);
|
||||
}
|
||||
|
||||
// 5/7. Return ? MakeSuperPropertyReference(actualThis, propertyKey, strict).
|
||||
|
@ -628,6 +634,7 @@ CodeGenerationErrorOr<Generator::ReferenceOperands> Generator::emit_super_refere
|
|||
return ReferenceOperands {
|
||||
.base = base_value,
|
||||
.referenced_name = computed_property_value,
|
||||
.referenced_identifier = property_key_id,
|
||||
.this_value = actual_this,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue