summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-05-01 00:47:55 +0200
committerLinus Groh <mail@linusgroh.de>2022-05-01 22:47:38 +0200
commitcb66474fb55ddd7e5b9f7186caf4a9c180518126 (patch)
treebd3a2944220dea89b4f2da14e8fa0c4781379a07
parentd33fcad87fc122ad48a0eec99d14f45f37ae86d1 (diff)
downloadserenity-cb66474fb55ddd7e5b9f7186caf4a9c180518126.zip
LibJS: Update spec comments testing presence of a field
This is an editorial change in the ECMA-262 spec. See: - https://github.com/tc39/ecma262/commit/497f99a - https://github.com/tc39/ecma262/commit/0b35749
-rw-r--r--Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/Array.cpp12
-rw-r--r--Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp10
4 files changed, 20 insertions, 20 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
index 4282ed99bc..b81e24707b 100644
--- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp
@@ -284,11 +284,11 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p
// 5. If current.[[Configurable]] is false, then
if (!*current->configurable) {
- // a. If Desc.[[Configurable]] is present and its value is true, return false.
+ // a. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is true, return false.
if (descriptor.configurable.has_value() && *descriptor.configurable)
return false;
- // b. If Desc.[[Enumerable]] is present and ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false.
+ // b. If Desc has an [[Enumerable]] field and ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false.
if (descriptor.enumerable.has_value() && *descriptor.enumerable != *current->enumerable)
return false;
@@ -298,22 +298,22 @@ bool validate_and_apply_property_descriptor(Object* object, PropertyKey const& p
// d. If ! IsAccessorDescriptor(Desc) is true, then
if (descriptor.is_accessor_descriptor()) {
- // i. If Desc.[[Get]] is present and ! SameValue(Desc.[[Get]], current.[[Get]]) is false, return false.
+ // i. If Desc has a [[Get]] field and ! SameValue(Desc.[[Get]], current.[[Get]]) is false, return false.
if (descriptor.get.has_value() && *descriptor.get != *current->get)
return false;
- // ii. If Desc.[[Set]] is present and ! SameValue(Desc.[[Set]], current.[[Set]]) is false, return false.
+ // ii. If Desc has a [[Set]] field and ! SameValue(Desc.[[Set]], current.[[Set]]) is false, return false.
if (descriptor.set.has_value() && *descriptor.set != *current->set)
return false;
}
// e. Else if current.[[Writable]] is false, then
// FIXME: `current` is not guaranteed to be a data descriptor at this point and may not have a [[Writable]] field (see https://github.com/tc39/ecma262/issues/2761)
else if (current->is_data_descriptor() && !*current->writable) {
- // i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false.
+ // i. If Desc has a [[Writable]] field and Desc.[[Writable]] is true, return false.
if (descriptor.writable.has_value() && *descriptor.writable)
return false;
- // ii. If Desc.[[Value]] is present and ! SameValue(Desc.[[Value]], current.[[Value]]) is false, return false.
+ // ii. If Desc has a [[Value]] field and ! SameValue(Desc.[[Value]], current.[[Value]]) is false, return false.
if (descriptor.value.has_value() && (*descriptor.value != *current->value))
return false;
}
diff --git a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
index 6b98f8a294..14e3605067 100644
--- a/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/ArgumentsObject.cpp
@@ -139,7 +139,7 @@ ThrowCompletionOr<bool> ArgumentsObject::internal_define_own_property(PropertyKe
// 4. If isMapped is true and IsDataDescriptor(Desc) is true, then
if (is_mapped && descriptor.is_data_descriptor()) {
- // a. If Desc.[[Value]] is not present and Desc.[[Writable]] is present and its value is false, then
+ // a. If Desc does not have a [[Value]] field and Desc has a [[Writable]] field, and Desc.[[Writable]] is false, then
if (!descriptor.value.has_value() && descriptor.writable.has_value() && descriptor.writable == false) {
// i. Set newArgDesc to a copy of Desc.
new_arg_desc = descriptor;
@@ -162,7 +162,7 @@ ThrowCompletionOr<bool> ArgumentsObject::internal_define_own_property(PropertyKe
// i. Call map.[[Delete]](P).
MUST(map.internal_delete(property_key));
} else {
- // i. If Desc.[[Value]] is present, then
+ // i. If Desc has a [[Value]] field, then
if (descriptor.value.has_value()) {
// 1. Let setStatus be Set(map, P, Desc.[[Value]], false).
bool set_status = MUST(map.set(property_key, descriptor.value.value(), Object::ShouldThrowExceptions::No));
@@ -170,7 +170,7 @@ ThrowCompletionOr<bool> ArgumentsObject::internal_define_own_property(PropertyKe
// 2. Assert: setStatus is true because formal parameters mapped by argument objects are always writable.
VERIFY(set_status);
}
- // ii. If Desc.[[Writable]] is present and its value is false, then
+ // ii. If Desc has a [[Writable]] field and Desc.[[Writable]] is false, then
if (descriptor.writable == false) {
// 1. Call map.[[Delete]](P).
MUST(map.internal_delete(property_key));
diff --git a/Userland/Libraries/LibJS/Runtime/Array.cpp b/Userland/Libraries/LibJS/Runtime/Array.cpp
index d8969b17a8..56ce0c9332 100644
--- a/Userland/Libraries/LibJS/Runtime/Array.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Array.cpp
@@ -56,7 +56,7 @@ ThrowCompletionOr<bool> Array::set_length(PropertyDescriptor const& property_des
auto& global_object = this->global_object();
auto& vm = this->vm();
- // 1. If Desc.[[Value]] is absent, then
+ // 1. If Desc does not have a [[Value]] field, then
// a. Return OrdinaryDefineOwnProperty(A, "length", Desc).
// 2. Let newLenDesc be a copy of Desc.
// NOTE: Handled by step 16
@@ -82,7 +82,7 @@ ThrowCompletionOr<bool> Array::set_length(PropertyDescriptor const& property_des
// 12. If oldLenDesc.[[Writable]] is false, return false.
// NOTE: Handled by step 16
- // 13. If newLenDesc.[[Writable]] is absent or is true, let newWritable be true.
+ // 13. If newLenDesc does not have a [[Writable]] field or newLenDesc.[[Writable]] true, let newWritable be true.
// 14. Else,
// a. NOTE: Setting the [[Writable]] attribute to false is deferred in case any elements cannot be deleted.
// b. Let newWritable be false.
@@ -97,10 +97,10 @@ ThrowCompletionOr<bool> Array::set_length(PropertyDescriptor const& property_des
// 10.1.6.3 ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ), https://tc39.es/ecma262/#sec-validateandapplypropertydescriptor
// 5. If current.[[Configurable]] is false, then
- // a. If Desc.[[Configurable]] is present and its value is true, return false.
+ // a. If Desc has a [[Configurable]] field and Desc.[[Configurable]] is true, return false.
if (property_descriptor.configurable.has_value() && *property_descriptor.configurable)
return false;
- // b. If Desc.[[Enumerable]] is present and ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false.
+ // b. If Desc has an [[Enumerable]] field and ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false.
if (property_descriptor.enumerable.has_value() && *property_descriptor.enumerable)
return false;
// c. If ! IsGenericDescriptor(Desc) is false and ! SameValue(IsAccessorDescriptor(Desc), IsAccessorDescriptor(current)) is false, return false.
@@ -109,10 +109,10 @@ ThrowCompletionOr<bool> Array::set_length(PropertyDescriptor const& property_des
// NOTE: Step d. doesn't apply here.
// e. Else if current.[[Writable]] is false, then
if (!m_length_writable) {
- // i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false.
+ // i. If Desc has a [[Writable]] field and Desc.[[Writable]] is true, return false.
if (property_descriptor.writable.has_value() && *property_descriptor.writable)
return false;
- // ii. If Desc.[[Value]] is present and ! SameValue(Desc.[[Value]], current.[[Value]]) is false, return false.
+ // ii. If Desc has a [[Value]] field and SameValue(Desc.[[Value]], current.[[Value]]) is false, return false.
if (new_length != indexed_properties().array_like_size())
return false;
}
diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp
index da694c9550..270420aebc 100644
--- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2021-2022, Linus Groh <linusg@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -18,7 +18,7 @@ bool PropertyDescriptor::is_accessor_descriptor() const
{
// 1. If Desc is undefined, return false.
- // 2. If both Desc.[[Get]] and Desc.[[Set]] are absent, return false.
+ // 2. If Desc does not have a [[Get]] field and Desc does not have a [[Set]] field, return false.
if (!get.has_value() && !set.has_value())
return false;
@@ -31,7 +31,7 @@ bool PropertyDescriptor::is_data_descriptor() const
{
// 1. If Desc is undefined, return false.
- // 2. If both Desc.[[Value]] and Desc.[[Writable]] are absent, return false.
+ // 2. If Desc does not have a [[Value]] field and Desc does not have a [[Writable]] field, return false.
if (!value.has_value() && !writable.has_value())
return false;
@@ -168,9 +168,9 @@ ThrowCompletionOr<PropertyDescriptor> to_property_descriptor(GlobalObject& globa
descriptor.set = setter.is_function() ? &setter.as_function() : nullptr;
}
- // 15. If desc.[[Get]] is present or desc.[[Set]] is present, then
+ // 15. If desc has a [[Get]] field or desc has a [[Set]] field, then
if (descriptor.get.has_value() || descriptor.set.has_value()) {
- // a. If desc.[[Value]] is present or desc.[[Writable]] is present, throw a TypeError exception.
+ // a. If desc has a [[Value]] field or desc has a [[Writable]] field, throw a TypeError exception.
if (descriptor.value.has_value() || descriptor.writable.has_value())
return vm.throw_completion<TypeError>(global_object, ErrorType::AccessorValueOrWritable);
}