mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:17:45 +00:00
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:
parent
e0d26fff8c
commit
37c4fbb6ca
4 changed files with 50 additions and 9 deletions
|
@ -201,12 +201,18 @@ private:
|
|||
Function,
|
||||
Block,
|
||||
};
|
||||
struct HoistableDeclaration {
|
||||
NonnullRefPtr<FunctionDeclaration> declaration;
|
||||
NonnullRefPtr<Scope> scope; // where it is actually declared
|
||||
};
|
||||
|
||||
Type type;
|
||||
RefPtr<Scope> parent;
|
||||
|
||||
NonnullRefPtrVector<FunctionDeclaration> function_declarations;
|
||||
NonnullRefPtrVector<FunctionDeclaration> hoisted_function_declarations;
|
||||
Vector<HoistableDeclaration> hoisted_function_declarations;
|
||||
|
||||
HashTable<FlyString> lexical_declarations;
|
||||
|
||||
explicit Scope(Type, RefPtr<Scope>);
|
||||
RefPtr<Scope> get_current_function_scope();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue