mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibJS: Allow usage of locals if function parameters have default values
Initially, the usage of local variables for parameters had to be
disabled when default values were used because there was a bug that
didn't allow to correctly find the scope to which identifiers used
within the default parameter expression belonged, and hence correctly
identify if a variable can be local. However, this bug was fixed in
2f85faef0f
, so now this restriction
is no longer needed.
This commit is contained in:
parent
59e8f713db
commit
c4656a70c1
Notes:
sideshowbarker
2024-07-17 10:08:28 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/c4656a70c1 Pull-request: https://github.com/SerenityOS/serenity/pull/19883
1 changed files with 0 additions and 7 deletions
|
@ -244,12 +244,9 @@ public:
|
|||
void set_function_parameters(Vector<FunctionParameter> const& parameters)
|
||||
{
|
||||
m_function_parameters = parameters;
|
||||
auto has_parameters_with_default_values = false;
|
||||
for (auto& parameter : parameters) {
|
||||
parameter.binding.visit(
|
||||
[&](Identifier const& identifier) {
|
||||
if (parameter.default_value)
|
||||
has_parameters_with_default_values = true;
|
||||
register_identifier(identifier);
|
||||
m_function_parameters_candidates_for_local_variables.set(identifier.string());
|
||||
m_forbidden_lexical_names.set(identifier.string());
|
||||
|
@ -261,10 +258,6 @@ public:
|
|||
}));
|
||||
});
|
||||
}
|
||||
|
||||
if (has_parameters_with_default_values) {
|
||||
m_function_parameters_candidates_for_local_variables.clear();
|
||||
}
|
||||
}
|
||||
|
||||
~ScopePusher()
|
||||
|
|
Loading…
Reference in a new issue