mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:47:34 +00:00
LibJS: Use ToPropertyKey AO for computed member expression value
This ensures the value goes through the regular ToPrimitive mechanism, which PropertyKey::from_value() bypasses. This is relevant for objects with a @@toPrimitive method, for example. Also enables one skipped test in delete-basic.js, which now passes.
This commit is contained in:
parent
227d860d6b
commit
5ee1758f46
2 changed files with 2 additions and 3 deletions
|
@ -1482,7 +1482,7 @@ ThrowCompletionOr<Reference> MemberExpression::to_reference(Interpreter& interpr
|
||||||
|
|
||||||
TRY(require_object_coercible(vm, base_value));
|
TRY(require_object_coercible(vm, base_value));
|
||||||
|
|
||||||
property_key = TRY(PropertyKey::from_value(vm, value));
|
property_key = TRY(value.to_property_key(vm));
|
||||||
} else if (is<PrivateIdentifier>(*m_property)) {
|
} else if (is<PrivateIdentifier>(*m_property)) {
|
||||||
auto& private_identifier = static_cast<PrivateIdentifier const&>(*m_property);
|
auto& private_identifier = static_cast<PrivateIdentifier const&>(*m_property);
|
||||||
return make_private_reference(interpreter.vm(), base_value, private_identifier.string());
|
return make_private_reference(interpreter.vm(), base_value, private_identifier.string());
|
||||||
|
|
|
@ -166,8 +166,7 @@ test("deleting an object computed property coerces the object to a property key"
|
||||||
expect(called).toBeTrue();
|
expect(called).toBeTrue();
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: This currently does not work as it trys to coerce the returned Symbol to a String. I'm not sure why this is.
|
test("deleting a symbol returned by @@toPrimitive", () => {
|
||||||
test.skip("deleting a symbol returned by @@toPrimitive", () => {
|
|
||||||
let called = false;
|
let called = false;
|
||||||
const obj = { [Symbol.toStringTag]: "hello world" };
|
const obj = { [Symbol.toStringTag]: "hello world" };
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue