mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-13 13:02:28 +00:00
LibJS: Treat the Catch binding identifier as a var binding
This commit is contained in:
parent
6ab6321c2f
commit
da296ffd56
Notes:
sideshowbarker
2024-07-18 02:55:48 +09:00
Author: https://github.com/alimpfard
Commit: da296ffd56
Pull-request: https://github.com/SerenityOS/serenity/pull/10390
Reviewed-by: https://github.com/awesomekling ✅
Reviewed-by: https://github.com/davidot
1 changed files with 4 additions and 2 deletions
|
@ -82,13 +82,15 @@ public:
|
||||||
return scope_pusher;
|
return scope_pusher;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ScopePusher catch_scope(Parser& parser, RefPtr<BindingPattern> const& pattern)
|
static ScopePusher catch_scope(Parser& parser, RefPtr<BindingPattern> const& pattern, FlyString const& parameter)
|
||||||
{
|
{
|
||||||
ScopePusher scope_pusher(parser, nullptr, false);
|
ScopePusher scope_pusher(parser, nullptr, false);
|
||||||
if (pattern) {
|
if (pattern) {
|
||||||
pattern->for_each_bound_name([&](auto const& name) {
|
pattern->for_each_bound_name([&](auto const& name) {
|
||||||
scope_pusher.m_forbidden_var_names.set(name);
|
scope_pusher.m_forbidden_var_names.set(name);
|
||||||
});
|
});
|
||||||
|
} else if (!parameter.is_empty()) {
|
||||||
|
scope_pusher.m_var_names.set(parameter);
|
||||||
}
|
}
|
||||||
return scope_pusher;
|
return scope_pusher;
|
||||||
}
|
}
|
||||||
|
@ -2709,7 +2711,7 @@ NonnullRefPtr<CatchClause> Parser::parse_catch_clause()
|
||||||
bound_names.set(parameter);
|
bound_names.set(parameter);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopePusher catch_scope = ScopePusher::catch_scope(*this, pattern_parameter);
|
ScopePusher catch_scope = ScopePusher::catch_scope(*this, pattern_parameter, parameter);
|
||||||
auto body = parse_block_statement();
|
auto body = parse_block_statement();
|
||||||
|
|
||||||
body->for_each_lexically_declared_name([&](auto const& name) {
|
body->for_each_lexically_declared_name([&](auto const& name) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue