mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-07 10:06:03 +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
Notes:
sideshowbarker
2024-07-18 10:16:13 +09:00
Author: https://github.com/Hendi48
Commit: 37c4fbb6ca
Pull-request: https://github.com/SerenityOS/serenity/pull/8508
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