diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index e0711f213d..d4d97e52a4 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -976,7 +976,12 @@ Bytecode::CodeGenerationErrorOr 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)); } diff --git a/Userland/Libraries/LibJS/Tests/object-basic.js b/Userland/Libraries/LibJS/Tests/object-basic.js index f04b87ffcf..879a0a114a 100644 --- a/Userland/Libraries/LibJS/Tests/object-basic.js +++ b/Userland/Libraries/LibJS/Tests/object-basic.js @@ -221,13 +221,13 @@ describe("naming of anon functions", () => { expect({ func() {} }.func.name).toBe("func"); }); - test.xfail("getter has name", () => { + test("getter has name", () => { expect(Object.getOwnPropertyDescriptor({ get func() {} }, "func").get.name).toBe( "get func" ); }); - test.xfail("setter has name", () => { + test("setter has name", () => { expect(Object.getOwnPropertyDescriptor({ set func(v) {} }, "func").set.name).toBe( "set func" );