mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 15:27:35 +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:
parent
0cd85ab0fc
commit
d165590809
2 changed files with 16 additions and 7 deletions
|
@ -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)");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue