mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibJS: Assign getter/setter function names as early as possible
In case of {get func() {}, set func() {}} we were wrongly setting the
function name to 'func' and then later trying to replace an empty name
with 'get func'/'set func' which failed.
Instead, set the name to 'get func'/'set func' right away.
The code in put_by_property_key is kept, for when that is called
by put_by_value.
This commit is contained in:
committed by
Andreas Kling
parent
a3f34263fd
commit
b9c9315bcb
@@ -976,7 +976,12 @@ Bytecode::CodeGenerationErrorOr<void> ObjectExpression::generate_bytecode(Byteco
|
||||
if (property_kind == Bytecode::Op::PropertyKind::ProtoSetter) {
|
||||
TRY(property->value().generate_bytecode(generator));
|
||||
} else if (property_kind != Bytecode::Op::PropertyKind::Spread) {
|
||||
auto name = generator.intern_identifier(string_literal.value());
|
||||
DeprecatedString identifier = string_literal.value();
|
||||
if (property_kind == Bytecode::Op::PropertyKind::Getter)
|
||||
identifier = DeprecatedString::formatted("get {}", identifier);
|
||||
else if (property_kind == Bytecode::Op::PropertyKind::Setter)
|
||||
identifier = DeprecatedString::formatted("set {}", identifier);
|
||||
auto name = generator.intern_identifier(identifier);
|
||||
TRY(generator.emit_named_evaluation_if_anonymous_function(property->value(), name));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user