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

LibJS: Throw on failed PutValue into an environment reference

This should really be handled at a different layer of the stack, but
this allows us to make progress on the Object rewrite without breaking
strict mode assignment tests.
This commit is contained in:
Andreas Kling 2021-07-02 00:32:23 +02:00
parent 80170887db
commit a4897ed7b2

View file

@ -60,7 +60,15 @@ void Reference::put_value(GlobalObject& global_object, Value value)
return;
}
m_base_environment->put_into_environment(m_name.as_string(), variable);
bool succeeded = m_base_environment->put_into_environment(m_name.as_string(), variable);
if (vm.exception())
return;
if (!succeeded && m_strict) {
// FIXME: This is a hack and will disappear when we support proper variable bindings.
vm.throw_exception<TypeError>(global_object, ErrorType::DescWriteNonWritable, m_name.to_value(vm).to_string_without_side_effects());
return;
}
}
void Reference::throw_reference_error(GlobalObject& global_object)