[webkit-changes] [WebKit/WebKit] 681701: Temporal API should throw TypeErrors for unexpecte...

Ross Kirsling noreply at github.com
Mon Nov 6 03:25:29 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 681701c7e39b6750bdd27c95497e8dcbc361176b
      https://github.com/WebKit/WebKit/commit/681701c7e39b6750bdd27c95497e8dcbc361176b
  Author: Ross Kirsling <rkirsling at gmail.com>
  Date:   2023-11-06 (Mon, 06 Nov 2023)

  Changed paths:
    M JSTests/stress/temporal-duration.js
    M JSTests/stress/temporal-plaindatetime.js
    M JSTests/test262/config.yaml
    M JSTests/test262/expectations.yaml
    M Source/JavaScriptCore/runtime/JSCJSValue.h
    M Source/JavaScriptCore/runtime/JSCJSValueInlines.h
    M Source/JavaScriptCore/runtime/TemporalDuration.cpp
    M Source/JavaScriptCore/runtime/TemporalDurationConstructor.cpp
    M Source/JavaScriptCore/runtime/TemporalInstant.cpp
    M Source/JavaScriptCore/runtime/TemporalPlainDate.cpp
    M Source/JavaScriptCore/runtime/TemporalPlainDateConstructor.cpp
    M Source/JavaScriptCore/runtime/TemporalPlainDateTime.cpp
    M Source/JavaScriptCore/runtime/TemporalPlainTime.cpp

  Log Message:
  -----------
  Temporal API should throw TypeErrors for unexpected primitives
https://bugs.webkit.org/show_bug.cgi?id=264240

Reviewed by Yusuke Suzuki.

As of the latest Temporal spec, we should never convert non-object, non-string values to a Temporal object.
At our current stage of implementation, this applies to Duration, Instant, PlainDate, PlainTime, and PlainDateTime.

Relatedly (namely, for the case of handling explicit undefined values),
toIntegerOrInfinity is no longer used by Temporal and toIntegerWithoutRounding has been removed entirely.
Spec-side, these have been replaced by toIntegerWithTruncation and toIntegerIfIntegral;
here, we implement the former and inline the latter.

* JSTests/test262/config.yaml:
Move two tests over from expectations.yaml;
even before this patch, these are hitting an assertion due to unimplemented parts of Temporal.

* JSTests/test262/expectations.yaml:
Mark 102 test cases passing.

* JSTests/stress/temporal-duration.js:
* JSTests/stress/temporal-plaindatetime.js:
* Source/JavaScriptCore/runtime/JSCJSValue.h:
* Source/JavaScriptCore/runtime/JSCJSValueInlines.h:
(JSC::JSValue::toIntegerWithTruncation const):
(JSC::JSValue::toIntegerOrInfinity const):
(JSC::JSValue::toIntegerWithoutRounding const): Deleted.
* Source/JavaScriptCore/runtime/TemporalDuration.cpp:
(JSC::TemporalDuration::fromDurationLike):
(JSC::TemporalDuration::toISO8601Duration):
* Source/JavaScriptCore/runtime/TemporalDurationConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/TemporalInstant.cpp:
* Source/JavaScriptCore/runtime/TemporalPlainDate.cpp:
(JSC::TemporalPlainDate::from):
* Source/JavaScriptCore/runtime/TemporalPlainDateConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
* Source/JavaScriptCore/runtime/TemporalPlainDateTime.cpp:
(JSC::TemporalPlainDateTime::from):
* Source/JavaScriptCore/runtime/TemporalPlainTime.cpp:
(JSC::TemporalPlainTime::from):

Canonical link: https://commits.webkit.org/270262@main




More information about the webkit-changes mailing list