Jelajahi Sumber

LibJS: Update a couple of outdated spec comments

These are editorial changes in the ECMA-262 spec.

See:
- https://github.com/tc39/ecma262/commit/e080a7f
- https://github.com/tc39/ecma262/commit/c5a9094
- https://github.com/tc39/ecma262/commit/5091520
- https://github.com/tc39/ecma262/commit/1c6564b
- https://github.com/tc39/ecma262/commit/e06c80c
Linus Groh 3 tahun lalu
induk
melakukan
5a26a547db

+ 1 - 1
Userland/Libraries/LibJS/AST.cpp

@@ -1381,7 +1381,7 @@ ThrowCompletionOr<Reference> MemberExpression::to_reference(Interpreter& interpr
             property_key = static_cast<Identifier const&>(property()).string();
         }
 
-        // 6. If the code matched by this SuperProperty is strict mode code, let strict be true; else let strict be false.
+        // 6. If the source text matched by this SuperProperty is strict mode code, let strict be true; else let strict be false.
         bool strict = interpreter.vm().in_strict_mode();
 
         // 7. Return ? MakeSuperPropertyReference(actualThis, propertyKey, strict).

+ 6 - 3
Userland/Libraries/LibJS/Parser.cpp

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2020, Stephan Unverwerth <s.unverwerth@serenityos.org>
- * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
  * Copyright (c) 2021-2022, David Tuin <davidot@serenityos.org>
  * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
@@ -3343,9 +3343,12 @@ NonnullRefPtr<IfStatement> Parser::parse_if_statement()
     auto rule_start = push_start();
     auto parse_function_declaration_as_block_statement = [&] {
         // https://tc39.es/ecma262/#sec-functiondeclarations-in-ifstatement-statement-clauses
-        // Code matching this production is processed as if each matching occurrence of
+        // This production only applies when parsing non-strict code. Source text matched
+        // by this production is processed as if each matching occurrence of
         // FunctionDeclaration[?Yield, ?Await, ~Default] was the sole StatementListItem
-        // of a BlockStatement occupying that position in the source code.
+        // of a BlockStatement occupying that position in the source text.
+        // The semantics of such a synthetic BlockStatement includes the web legacy
+        // compatibility semantics specified in B.3.2.
         VERIFY(match(TokenType::Function));
         auto block = create_ast_node<BlockStatement>({ m_state.current_token.filename(), rule_start.position(), position() });
         ScopePusher block_scope = ScopePusher::block_scope(*this, *block);

+ 2 - 2
Userland/Libraries/LibJS/Runtime/Array.cpp

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
- * Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
+ * Copyright (c) 2020-2022, Linus Groh <linusg@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
@@ -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 has the value true, let newWritable be true.
+    // 13. If newLenDesc.[[Writable]] is absent or is 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.

+ 1 - 2
Userland/Libraries/LibJS/Runtime/DatePrototype.cpp

@@ -94,8 +94,7 @@ void DatePrototype::initialize(GlobalObject& global_object)
     define_native_function(vm.names.valueOf, get_time, 0, attr);
 
     // B.2.4.3 Date.prototype.toGMTString ( ), https://tc39.es/ecma262/#sec-date.prototype.togmtstring
-    // The function object that is the initial value of Date.prototype.toGMTString
-    // is the same function object that is the initial value of Date.prototype.toUTCString.
+    // The initial value of the "toGMTString" property is %Date.prototype.toUTCString%, defined in 21.4.4.43.
     define_direct_property(vm.names.toGMTString, get_without_side_effects(vm.names.toUTCString), attr);
 }
 

+ 1 - 1
Userland/Libraries/LibJS/Runtime/FunctionEnvironment.cpp

@@ -32,7 +32,7 @@ ThrowCompletionOr<Value> FunctionEnvironment::get_super_base() const
     // 1. Let home be envRec.[[FunctionObject]].[[HomeObject]].
     auto home_object = m_function_object->home_object();
 
-    // 2. If home has the value undefined, return undefined.
+    // 2. If home is undefined, return undefined.
     if (!home_object)
         return js_undefined();
 

+ 1 - 1
Userland/Libraries/LibJS/Runtime/VM.cpp

@@ -582,7 +582,7 @@ ThrowCompletionOr<Reference> VM::resolve_binding(FlyString const& name, Environm
     // 2. Assert: env is an Environment Record.
     VERIFY(environment);
 
-    // 3. If the code matching the syntactic production that is being evaluated is contained in strict mode code, let strict be true; else let strict be false.
+    // 3. If the source text matched by the syntactic production that is being evaluated is contained in strict mode code, let strict be true; else let strict be false.
     bool strict = in_strict_mode();
 
     // 4. Return ? GetIdentifierReference(env, name, strict).