mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
LibJS: No longer hoist if parent scope has a function with the same name
This commit is contained in:
parent
54b2d8c1b8
commit
5ca6e8dca8
2 changed files with 357 additions and 3 deletions
|
@ -235,10 +235,12 @@ public:
|
|||
auto const& function_declaration = m_functions_to_hoist[i];
|
||||
if (m_lexical_names.contains(function_declaration.name()) || m_forbidden_var_names.contains(function_declaration.name()))
|
||||
continue;
|
||||
if (is_top_level())
|
||||
if (is_top_level()) {
|
||||
m_node->add_hoisted_function(move(m_functions_to_hoist[i]));
|
||||
else
|
||||
m_parent_scope->m_functions_to_hoist.append(move(m_functions_to_hoist[i]));
|
||||
} else {
|
||||
if (!m_parent_scope->m_lexical_names.contains(function_declaration.name()) && !m_parent_scope->m_function_names.contains(function_declaration.name()))
|
||||
m_parent_scope->m_functions_to_hoist.append(move(m_functions_to_hoist[i]));
|
||||
}
|
||||
}
|
||||
|
||||
if (m_parent_scope && !m_function_parameters.has_value()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue