mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-19 15:32:31 +00:00
LibJS: Remove [[VarNames]] from GlobalEnvironment
This is a normative change in the ECMA-262 spec. See:
ed75310
This commit is contained in:
parent
9c85a16aeb
commit
15faaeb2bb
Notes:
github-actions[bot]
2025-04-29 11:34:32 +00:00
Author: https://github.com/trflynn89
Commit: 15faaeb2bb
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4514
5 changed files with 35 additions and 51 deletions
|
@ -1693,17 +1693,16 @@ ThrowCompletionOr<void> Program::global_declaration_instantiation(VM& vm, Global
|
|||
TRY(for_each_lexically_declared_identifier([&](Identifier const& identifier) -> ThrowCompletionOr<void> {
|
||||
auto const& name = identifier.string();
|
||||
|
||||
// a. If env.HasVarDeclaration(name) is true, throw a SyntaxError exception.
|
||||
if (global_environment.has_var_declaration(name))
|
||||
return vm.throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name);
|
||||
|
||||
// b. If env.HasLexicalDeclaration(name) is true, throw a SyntaxError exception.
|
||||
// a. If HasLexicalDeclaration(env, name) is true, throw a SyntaxError exception.
|
||||
if (global_environment.has_lexical_declaration(name))
|
||||
return vm.throw_completion<SyntaxError>(ErrorType::TopLevelVariableAlreadyDeclared, name);
|
||||
|
||||
// c. Let hasRestrictedGlobal be ? env.HasRestrictedGlobalProperty(name).
|
||||
// b. Let hasRestrictedGlobal be ? HasRestrictedGlobalProperty(env, name).
|
||||
auto has_restricted_global = TRY(global_environment.has_restricted_global_property(name));
|
||||
|
||||
// c. NOTE: Global var and function bindings (except those that are introduced by non-strict direct eval) are
|
||||
// non-configurable and are therefore restricted global properties.
|
||||
|
||||
// d. If hasRestrictedGlobal is true, throw a SyntaxError exception.
|
||||
if (has_restricted_global)
|
||||
return vm.throw_completion<SyntaxError>(ErrorType::RestrictedGlobalProperty, name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue