Title: [293811] trunk
- Revision
- 293811
- Author
- ross.kirsl...@sony.com
- Date
- 2022-05-04 18:34:14 -0700 (Wed, 04 May 2022)
Log Message
Temporal.Duration constructor should throw on non-integers
https://bugs.webkit.org/show_bug.cgi?id=240094
Reviewed by Yusuke Suzuki.
Belated implementation for https://github.com/tc39/proposal-temporal/pull/1872 --
this patch makes `new Temporal.Duration(1.1)` throw just as `Temporal.Duration.from({ years: 1.1 })` does.
* test262/expectations.yaml:
Mark two test cases as passing.
* runtime/TemporalDurationConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
Canonical link: https://commits.webkit.org/250284@main
Modified Paths
Diff
Modified: trunk/JSTests/ChangeLog (293810 => 293811)
--- trunk/JSTests/ChangeLog 2022-05-05 01:14:59 UTC (rev 293810)
+++ trunk/JSTests/ChangeLog 2022-05-05 01:34:14 UTC (rev 293811)
@@ -1,3 +1,13 @@
+2022-05-04 Ross Kirsling <ross.kirsl...@sony.com>
+
+ Temporal.Duration constructor should throw on non-integers
+ https://bugs.webkit.org/show_bug.cgi?id=240094
+
+ Reviewed by Yusuke Suzuki.
+
+ * test262/expectations.yaml:
+ Mark two test cases as passing.
+
2022-05-04 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Temporal.Instant since/until should not accept year / month / day / week units
Modified: trunk/JSTests/test262/expectations.yaml (293810 => 293811)
--- trunk/JSTests/test262/expectations.yaml 2022-05-05 01:14:59 UTC (rev 293810)
+++ trunk/JSTests/test262/expectations.yaml 2022-05-05 01:34:14 UTC (rev 293811)
@@ -876,9 +876,6 @@
test/built-ins/Temporal/Duration/compare/twenty-five-hour-day.js:
default: 'TypeError: Right side of assignment cannot be destructured'
strict mode: 'TypeError: Right side of assignment cannot be destructured'
-test/built-ins/Temporal/Duration/fractional-throws-rangeerror.js:
- default: 'Test262Error: Duration constructor throws RangeError with fractional value in the years position Expected a RangeError to be thrown but no exception was thrown at all'
- strict mode: 'Test262Error: Duration constructor throws RangeError with fractional value in the years position Expected a RangeError to be thrown but no exception was thrown at all'
test/built-ins/Temporal/Duration/prototype/add/argument-string-fractional-units-rounding-mode.js:
default: 'Test262Error: negative fractional units rounded with correct rounding mode microseconds result Expected SameValue(«-0», «0») to be true'
strict mode: 'Test262Error: negative fractional units rounded with correct rounding mode microseconds result Expected SameValue(«-0», «0») to be true'
Modified: trunk/Source/_javascript_Core/ChangeLog (293810 => 293811)
--- trunk/Source/_javascript_Core/ChangeLog 2022-05-05 01:14:59 UTC (rev 293810)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-05-05 01:34:14 UTC (rev 293811)
@@ -1,3 +1,16 @@
+2022-05-04 Ross Kirsling <ross.kirsl...@sony.com>
+
+ Temporal.Duration constructor should throw on non-integers
+ https://bugs.webkit.org/show_bug.cgi?id=240094
+
+ Reviewed by Yusuke Suzuki.
+
+ Belated implementation for https://github.com/tc39/proposal-temporal/pull/1872 --
+ this patch makes `new Temporal.Duration(1.1)` throw just as `Temporal.Duration.from({ years: 1.1 })` does.
+
+ * runtime/TemporalDurationConstructor.cpp:
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+
2022-05-04 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Temporal.Instant since/until should not accept year / month / day / week units
Modified: trunk/Source/_javascript_Core/runtime/TemporalDurationConstructor.cpp (293810 => 293811)
--- trunk/Source/_javascript_Core/runtime/TemporalDurationConstructor.cpp 2022-05-05 01:14:59 UTC (rev 293810)
+++ trunk/Source/_javascript_Core/runtime/TemporalDurationConstructor.cpp 2022-05-05 01:34:14 UTC (rev 293811)
@@ -92,11 +92,15 @@
ISO8601::Duration result;
auto count = std::min<size_t>(callFrame->argumentCount(), numberOfTemporalUnits);
for (size_t i = 0; i < count; i++) {
- result[i] = callFrame->uncheckedArgument(i).toIntegerOrInfinity(globalObject);
+ JSValue value = callFrame->uncheckedArgument(i);
+ if (value.isUndefined())
+ continue;
+
+ result[i] = value.toNumber(globalObject);
RETURN_IF_EXCEPTION(scope, { });
- if (!std::isfinite(result[i]))
- return throwVMRangeError(globalObject, scope, "Temporal.Duration properties must be finite"_s);
+ if (!isInteger(result[i]))
+ return throwVMRangeError(globalObject, scope, "Temporal.Duration properties must be integers"_s);
}
RELEASE_AND_RETURN(scope, JSValue::encode(TemporalDuration::tryCreateIfValid(globalObject, WTFMove(result), structure)));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes