LibJS: Handle symbol PropertyName in primitive assignment error

We can't just to_string() the PropertyName, it might be a symbol.
Instead to_value() it and then use to_string_without_side_effects() as
usual.

Fixes #4062.
This commit is contained in:
Linus Groh 2020-11-12 10:32:46 +00:00 committed by Andreas Kling
commit 5a307836c1
Notes: sideshowbarker 2024-07-19 01:25:33 +09:00
2 changed files with 4 additions and 1 deletions

View file

@ -5,5 +5,8 @@ test("basic functionality", () => {
expect(() => {
primitive.foo = "bar";
}).toThrowWithMessage(TypeError, "Cannot assign property foo to primitive value");
expect(() => {
primitive[Symbol.hasInstance] = 123;
}).toThrowWithMessage(TypeError, "Cannot assign property Symbol(Symbol.hasInstance) to primitive value");
});
});