Bläddra i källkod

LibJS: Remove unnecessary checks for undefined before ToPositiveInteger

This is an editorial change in the Temporal spec.

See: https://github.com/tc39/proposal-temporal/commit/9f3bf53
Linus Groh 3 år sedan
förälder
incheckning
c3567faa8c
1 ändrade filer med 4 tillägg och 4 borttagningar
  1. 4 4
      Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp

+ 4 - 4
Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp

@@ -227,11 +227,11 @@ ThrowCompletionOr<double> calendar_month(GlobalObject& global_object, Object& ca
     // 2. Let result be ? Invoke(calendar, "month", « dateLike »).
     // 2. Let result be ? Invoke(calendar, "month", « dateLike »).
     auto result = TRY(Value(&calendar).invoke(global_object, vm.names.month, &date_like));
     auto result = TRY(Value(&calendar).invoke(global_object, vm.names.month, &date_like));
 
 
-    // 3. If result is undefined, throw a RangeError exception.
+    // NOTE: Explicitly handled for a better error message similar to the other calendar property AOs
     if (result.is_undefined())
     if (result.is_undefined())
         return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.month.as_string(), vm.names.undefined.as_string());
         return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.month.as_string(), vm.names.undefined.as_string());
 
 
-    // 4. Return ? ToPositiveInteger(result).
+    // 3. Return ? ToPositiveInteger(result).
     return TRY(to_positive_integer(global_object, result));
     return TRY(to_positive_integer(global_object, result));
 }
 }
 
 
@@ -261,11 +261,11 @@ ThrowCompletionOr<double> calendar_day(GlobalObject& global_object, Object& cale
     // 2. Let result be ? Invoke(calendar, "day", « dateLike »).
     // 2. Let result be ? Invoke(calendar, "day", « dateLike »).
     auto result = TRY(Value(&calendar).invoke(global_object, vm.names.day, &date_like));
     auto result = TRY(Value(&calendar).invoke(global_object, vm.names.day, &date_like));
 
 
-    // 3. If result is undefined, throw a RangeError exception.
+    // NOTE: Explicitly handled for a better error message similar to the other calendar property AOs
     if (result.is_undefined())
     if (result.is_undefined())
         return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.day.as_string(), vm.names.undefined.as_string());
         return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidCalendarFunctionResult, vm.names.day.as_string(), vm.names.undefined.as_string());
 
 
-    // 4. Return ? ToPositiveInteger(result).
+    // 3. Return ? ToPositiveInteger(result).
     return TRY(to_positive_integer(global_object, result));
     return TRY(to_positive_integer(global_object, result));
 }
 }