mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 13:36:13 +03:00
LibJS: Skip bindings creation for locals during block declaration init
No need to create bindings for local variables as their values are not stored in an environment.
This commit is contained in:
parent
47eaef9b41
commit
4a9a1d1656
Notes:
sideshowbarker
2024-07-17 03:03:15 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/4a9a1d1656 Pull-request: https://github.com/SerenityOS/serenity/pull/19906 Reviewed-by: https://github.com/awesomekling ✅
@ -4757,7 +4757,13 @@ void ScopeNode::block_declaration_instantiation(VM& vm, Environment* environment
|
||||
auto is_constant_declaration = declaration.is_constant_declaration();
|
||||
// NOTE: Due to the use of MUST with `create_immutable_binding` and `create_mutable_binding` below,
|
||||
// an exception should not result from `for_each_bound_name`.
|
||||
MUST(declaration.for_each_bound_name([&](auto const& name) {
|
||||
MUST(declaration.for_each_bound_identifier([&](auto const& identifier) {
|
||||
if (vm.bytecode_interpreter_if_exists() && identifier.is_local()) {
|
||||
// NOTE: No need to create bindings for local variables as their values are not stored in an environment.
|
||||
return;
|
||||
}
|
||||
|
||||
auto const& name = identifier.string();
|
||||
if (is_constant_declaration) {
|
||||
MUST(environment->create_immutable_binding(vm, name, true));
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user