mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +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
c194afd17c
commit
3411d50737
4 changed files with 45 additions and 8 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