1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:55:08 +00:00

LibJS/Bytecode: Make setting failures throw only in strict mode

This commit is contained in:
Luke Wilde 2022-07-17 18:58:23 +01:00 committed by Linus Groh
parent 8568d18d7d
commit 12e3abc9e7

View file

@ -65,9 +65,12 @@ static ThrowCompletionOr<void> put_by_property_key(Object* object, Value value,
object->define_direct_accessor(name, nullptr, &function, Attribute::Configurable | Attribute::Enumerable);
break;
}
case PropertyKind::KeyValue:
TRY(object->set(name, interpreter.accumulator(), Object::ShouldThrowExceptions::Yes));
case PropertyKind::KeyValue: {
bool succeeded = TRY(object->internal_set(name, interpreter.accumulator(), object));
if (!succeeded && interpreter.vm().in_strict_mode())
return interpreter.vm().throw_completion<TypeError>(interpreter.global_object(), ErrorType::ReferenceNullishSetProperty, name, interpreter.accumulator().to_string_without_side_effects());
break;
}
case PropertyKind::Spread:
TRY(object->copy_data_properties(value, {}, interpreter.global_object()));
break;