LibJS: Don't hoist functions under certain circumstances

When a lexical declaration with the same name as a function exists,
the function is not hoisted (annex B).
This commit is contained in:
Hendi 2021-07-05 21:45:34 +02:00 committed by Linus Groh
commit 37c4fbb6ca
Notes: sideshowbarker 2024-07-18 10:16:13 +09:00
4 changed files with 50 additions and 9 deletions

View file

@ -2377,9 +2377,9 @@ void ScopeNode::add_functions(NonnullRefPtrVector<FunctionDeclaration> functions
m_functions.extend(move(functions));
}
void ScopeNode::add_hoisted_functions(NonnullRefPtrVector<FunctionDeclaration> hoisted_functions)
void ScopeNode::add_hoisted_function(NonnullRefPtr<FunctionDeclaration> hoisted_function)
{
m_hoisted_functions.extend(move(hoisted_functions));
m_hoisted_functions.append(hoisted_function);
}
}