mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibJS: Return the allocated dst register from deleting super properties
Even though calling delete on a super property will ultimately throw a ReferenceError, we must return the allocated register for the result of the delete operation (which would normally be a boolean). If the delete operation is used in a return statement, the bytecode generator for the return statement must be able to assume the statement had some output.
This commit is contained in:
parent
18dddaa742
commit
5947c37637
Notes:
github-actions[bot]
2024-12-14 20:09:41 +00:00
Author: https://github.com/trflynn89 Commit: https://github.com/LadybirdBrowser/ladybird/commit/5947c37637f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2903
2 changed files with 12 additions and 1 deletions
|
@ -812,7 +812,7 @@ CodeGenerationErrorOr<Optional<ScopedOperand>> Generator::emit_delete_reference(
|
|||
emit<Bytecode::Op::DeleteByIdWithThis>(dst, *super_reference.base, *super_reference.this_value, identifier_table_ref);
|
||||
}
|
||||
|
||||
return Optional<ScopedOperand> {};
|
||||
return dst;
|
||||
}
|
||||
|
||||
auto object = TRY(expression.object().generate_bytecode(*this)).value();
|
||||
|
|
|
@ -93,6 +93,13 @@ test("deleting super property", () => {
|
|||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
static foo() {
|
||||
const deleter = () => delete super.foo;
|
||||
deleter();
|
||||
}
|
||||
}
|
||||
|
||||
const obj = new B();
|
||||
expect(() => {
|
||||
obj.bar();
|
||||
|
@ -106,6 +113,10 @@ test("deleting super property", () => {
|
|||
expect(() => {
|
||||
C.foo();
|
||||
}).toThrowWithMessage(ReferenceError, "Can't delete a property on 'super'");
|
||||
|
||||
expect(() => {
|
||||
D.foo();
|
||||
}).toThrowWithMessage(ReferenceError, "Can't delete a property on 'super'");
|
||||
});
|
||||
|
||||
test("deleting an object computed property coerces the object to a property key", () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue