1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:37:44 +00:00

LibJS: Mark concrete method calls of Environment Records with ?/!

This is an editorial change in the ECMA-262 spec.

See: 7ae3ecf
This commit is contained in:
Linus Groh 2022-05-24 18:19:49 +01:00
parent cdc5ed2fb5
commit 89d4094709
3 changed files with 8 additions and 10 deletions

View file

@ -131,8 +131,7 @@ ThrowCompletionOr<void> DeclarativeEnvironment::set_mutable_binding(GlobalObject
if (strict)
return vm().throw_completion<ReferenceError>(global_object, ErrorType::UnknownIdentifier, name);
// FIXME: Should be `! envRec.CreateMutableBinding(N, true)` (see https://github.com/tc39/ecma262/pull/2764)
// b. Perform envRec.CreateMutableBinding(N, true).
// b. Perform ! envRec.CreateMutableBinding(N, true).
MUST(create_mutable_binding(global_object, name, true));
// c. Perform ! envRec.InitializeBinding(N, V).

View file

@ -59,8 +59,8 @@ ThrowCompletionOr<void> GlobalEnvironment::create_mutable_binding(GlobalObject&
if (MUST(m_declarative_record->has_binding(name)))
return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name);
// 3. Return DclRec.CreateMutableBinding(N, D).
return m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted);
// 3. Return ! DclRec.CreateMutableBinding(N, D).
return MUST(m_declarative_record->create_mutable_binding(global_object, name, can_be_deleted));
}
// 9.1.1.4.3 CreateImmutableBinding ( N, S ), https://tc39.es/ecma262/#sec-global-environment-records-createimmutablebinding-n-s
@ -71,8 +71,8 @@ ThrowCompletionOr<void> GlobalEnvironment::create_immutable_binding(GlobalObject
if (MUST(m_declarative_record->has_binding(name)))
return vm().throw_completion<TypeError>(global_object, ErrorType::GlobalEnvironmentAlreadyHasBinding, name);
// 3. Return DclRec.CreateImmutableBinding(N, S).
return m_declarative_record->create_immutable_binding(global_object, name, strict);
// 3. Return ! DclRec.CreateImmutableBinding(N, S).
return MUST(m_declarative_record->create_immutable_binding(global_object, name, strict));
}
// 9.1.1.4.4 InitializeBinding ( N, V ), https://tc39.es/ecma262/#sec-global-environment-records-initializebinding-n-v
@ -112,8 +112,7 @@ ThrowCompletionOr<Value> GlobalEnvironment::get_binding_value(GlobalObject& glob
// 1. Let DclRec be envRec.[[DeclarativeRecord]].
// 2. If ! DclRec.HasBinding(N) is true, then
if (MUST(m_declarative_record->has_binding(name))) {
// FIXME: Should be `! DclRec.GetBindingValue(N, S)` (see https://github.com/tc39/ecma262/pull/2764)
// a. Return DclRec.GetBindingValue(N, S).
// a. Return ? DclRec.GetBindingValue(N, S).
return m_declarative_record->get_binding_value(global_object, name, strict);
}

View file

@ -61,10 +61,10 @@ ThrowCompletionOr<void> SyntheticModule::link(VM& vm)
// 5. For each exportName in module.[[ExportNames]],
for (auto& export_name : m_export_names) {
// a. Perform ! envRec.CreateMutableBinding(exportName, false).
environment->create_mutable_binding(global_object, export_name, false);
MUST(environment->create_mutable_binding(global_object, export_name, false));
// b. Perform ! envRec.InitializeBinding(exportName, undefined).
environment->initialize_binding(global_object, export_name, js_undefined());
MUST(environment->initialize_binding(global_object, export_name, js_undefined()));
}
// 6. Return unused.