mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 20:35:13 +00:00
LibJS: Make PrimitiveString::deprecated_string() infallible
Work towards #20449.
This commit is contained in:
parent
c084269e5f
commit
09547ec975
17 changed files with 42 additions and 43 deletions
|
@ -68,14 +68,14 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage)
|
|||
return execution_context->lexical_environment != nullptr;
|
||||
});
|
||||
if (!outer_environment.has_value())
|
||||
return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, TRY(variable_name.deprecated_string()));
|
||||
return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, variable_name.deprecated_string());
|
||||
|
||||
auto reference = TRY(vm.resolve_binding(TRY(variable_name.deprecated_string()), outer_environment.value()->lexical_environment));
|
||||
auto reference = TRY(vm.resolve_binding(variable_name.deprecated_string(), outer_environment.value()->lexical_environment));
|
||||
|
||||
auto value = TRY(reference.get_value(vm));
|
||||
|
||||
if (!can_be_held_weakly(value))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", TRY(variable_name.deprecated_string())));
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", variable_name.deprecated_string()));
|
||||
|
||||
vm.heap().uproot_cell(&value.as_cell());
|
||||
TRY(reference.delete_(vm));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue