LibJS: Throw in strict mode when assigning property to primitive value

This commit is contained in:
Linus Groh 2020-05-28 17:48:25 +01:00 committed by Andreas Kling
commit 8ff4587f65
Notes: sideshowbarker 2024-07-19 06:01:27 +09:00
3 changed files with 25 additions and 5 deletions

View file

@ -50,6 +50,11 @@ void Reference::put(Interpreter& interpreter, Value value)
return;
}
if (!base().is_object() && interpreter.in_strict_mode()) {
interpreter.throw_exception<TypeError>(String::format("Can't assign property %s to primitive value", m_name.to_string().characters()));
return;
}
auto* object = base().to_object(interpreter);
if (!object)
return;