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

LibJS: Convert ScopeNode declaration functions to ThrowCompletionOr

This removes a number of vm.exception() checks which are now caught
directly by TRY. Make use of these checks in
{Global, Eval}DeclarationInstantiation and while we're here add spec
comments.
This commit is contained in:
davidot 2022-02-07 13:31:01 +01:00 committed by Linus Groh
parent cc7a117f0f
commit 4136cbdb09
6 changed files with 462 additions and 305 deletions

View file

@ -550,20 +550,14 @@ void Parser::parse_module(Program& program)
auto const& exported_name = entry.local_or_import_name;
bool found = false;
program.for_each_lexically_declared_name([&](auto const& name) {
if (name == exported_name) {
if (name == exported_name)
found = true;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
if (found)
continue;
program.for_each_var_declared_name([&](auto const& name) {
if (name == exported_name) {
if (name == exported_name)
found = true;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
if (!found)
syntax_error(String::formatted("'{}' is not declared", exported_name));