1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:27:45 +00:00

LibJS/Bytecode: Do not coerce the receiver to Object for internal_set

This makes the behavior of `Symbol` correct in strict mode, wherein if
the receiver is a symbol primitive, assigning new properties should
throw a TypeError.
This commit is contained in:
Daniel Bertalan 2023-07-02 20:33:58 +02:00 committed by Linus Groh
parent 0cd85ab0fc
commit d165590809
2 changed files with 16 additions and 7 deletions

View file

@ -17,3 +17,11 @@ test("constructing symbol from symbol is an error", () => {
Symbol(Symbol("foo"));
}).toThrowWithMessage(TypeError, "Cannot convert symbol to string");
});
test("setting new properties on a symbol is an error in strict mode", () => {
"use strict";
var symbol = Symbol("foo");
expect(() => {
symbol.bar = 42;
}).toThrowWithMessage(TypeError, "Cannot set property 'bar' of Symbol(foo)");
});