diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-01-07 12:24:05 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2023-01-08 12:13:15 +0100 |
commit | 115baa7e32ba30cc409d52546a78ee97a9cd4f76 (patch) | |
tree | a1c12e8c450a667aa99c9f403c3ef0ce830f4dde /Tests/LibJS | |
parent | d793262beba3a113bed4c728b572a78583b43277 (diff) | |
download | serenity-115baa7e32ba30cc409d52546a78ee97a9cd4f76.zip |
LibJS+Everywhere: Make PrimitiveString and Utf16String fallible
This makes construction of Utf16String fallible in OOM conditions. The
immediate impact is that PrimitiveString must then be fallible as well,
as it may either transcode UTF-8 to UTF-16, or create a UTF-16 string
from ropes.
There are a couple of places where it is very non-trivial to propagate
the error further. A FIXME has been added to those locations.
Diffstat (limited to 'Tests/LibJS')
-rw-r--r-- | Tests/LibJS/test-js.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Tests/LibJS/test-js.cpp b/Tests/LibJS/test-js.cpp index 719217318c..d88214b2e4 100644 --- a/Tests/LibJS/test-js.cpp +++ b/Tests/LibJS/test-js.cpp @@ -62,14 +62,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, variable_name.deprecated_string()); + return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, TRY(variable_name.deprecated_string())); - auto reference = TRY(vm.resolve_binding(variable_name.deprecated_string(), outer_environment.value()->lexical_environment)); + auto reference = TRY(vm.resolve_binding(TRY(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 {}", variable_name.deprecated_string())); + return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", TRY(variable_name.deprecated_string()))); vm.heap().uproot_cell(&value.as_cell()); TRY(reference.delete_(vm)); |