LibJS: Handle strict mode for functions more correctly

If a function is strict (has 'use strict' directive) it cannot have
bindings, cannot have duplicated parameter names and cannot have some
reserved keywords and identifiers as parameter names.
The logic partly applies depending on whether we are already in strict
mode or the function contains 'use strict';
This commit is contained in:
davidot 2021-07-12 01:29:07 +02:00 committed by Andreas Kling
commit 5cc518f07a
Notes: sideshowbarker 2024-07-18 08:39:58 +09:00
2 changed files with 76 additions and 14 deletions

View file

@ -52,7 +52,7 @@ public:
NonnullRefPtr<Declaration> parse_declaration();
NonnullRefPtr<Statement> parse_statement();
NonnullRefPtr<BlockStatement> parse_block_statement();
NonnullRefPtr<BlockStatement> parse_block_statement(bool& is_strict);
NonnullRefPtr<BlockStatement> parse_block_statement(bool& is_strict, bool error_on_binding = false);
NonnullRefPtr<ReturnStatement> parse_return_statement();
NonnullRefPtr<VariableDeclaration> parse_variable_declaration(bool for_loop_variable_declaration = false);
NonnullRefPtr<Statement> parse_for_statement();