summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-05-16 20:25:31 +0100
committerLinus Groh <mail@linusgroh.de>2022-05-16 20:28:26 +0100
commit51e01b5a802bbe4dc697acea9cb78c0b7157cd64 (patch)
tree61c58e708a51e72aca3ac8a3a6308ee21851d512
parent33f53041e7b6547083bfdf7821cf10c7816168cd (diff)
downloadserenity-51e01b5a802bbe4dc697acea9cb78c0b7157cd64.zip
LibJS: Remove redundant TemporalDateString production
This is an editorial change in the Temporal spec. See: https://github.com/tc39/proposal-temporal/commit/41a8a5c
-rw-r--r--Userland/Libraries/LibJS/Runtime/ErrorTypes.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp25
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp9
-rw-r--r--Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h2
-rw-r--r--Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDate/PlainDate.from.js8
5 files changed, 8 insertions, 38 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
index e1ce08bf08..6c727d90a7 100644
--- a/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
+++ b/Userland/Libraries/LibJS/Runtime/ErrorTypes.h
@@ -226,8 +226,6 @@
M(TemporalInvalidCalendarFunctionResult, "Invalid calendar, {}() function returned {}") \
M(TemporalInvalidCalendarIdentifier, "Invalid calendar identifier '{}'") \
M(TemporalInvalidCalendarString, "Invalid calendar string '{}'") \
- M(TemporalInvalidDateString, "Invalid date string '{}'") \
- M(TemporalInvalidDateStringUTCDesignator, "Invalid date string '{}': must not contain a UTC designator") \
M(TemporalInvalidDateTimeString, "Invalid date time string '{}'") \
M(TemporalInvalidDateTimeStringUTCDesignator, "Invalid date time string '{}': must not contain a UTC designator") \
M(TemporalInvalidDuration, "Invalid duration") \
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
index 34e9dc4f52..c14c25e44f 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/AbstractOperations.cpp
@@ -1291,28 +1291,11 @@ ThrowCompletionOr<String> parse_temporal_calendar_string(GlobalObject& global_ob
// 13.35 ParseTemporalDateString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatestring
ThrowCompletionOr<TemporalDate> parse_temporal_date_string(GlobalObject& global_object, String const& iso_string)
{
- auto& vm = global_object.vm();
-
- // 1. Assert: Type(isoString) is String.
-
- // 2. If isoString does not satisfy the syntax of a TemporalDateString (see 13.33), then
- auto parse_result = parse_iso8601(Production::TemporalDateString, iso_string);
- if (!parse_result.has_value()) {
- // a. Throw a RangeError exception.
- return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateString, iso_string);
- }
-
- // 3. If isoString contains a UTCDesignator, then
- if (parse_result->utc_designator.has_value()) {
- // a. Throw a RangeError exception.
- return vm.throw_completion<RangeError>(global_object, ErrorType::TemporalInvalidDateStringUTCDesignator, iso_string);
- }
+ // 1. Let parts be ? ParseTemporalDateTimeString(isoString).
+ auto parts = TRY(parse_temporal_date_time_string(global_object, iso_string));
- // 4. Let result be ? ParseISODateTime(isoString).
- auto result = TRY(parse_iso_date_time(global_object, *parse_result));
-
- // 5. Return the Record { [[Year]]: result.[[Year]], [[Month]]: result.[[Month]], [[Day]]: result.[[Day]], [[Calendar]]: result.[[Calendar]] }.
- return TemporalDate { .year = result.year, .month = result.month, .day = result.day, .calendar = move(result.calendar) };
+ // 2. Return the Record { [[Year]]: parts.[[Year]], [[Month]]: parts.[[Month]], [[Day]]: parts.[[Day]], [[Calendar]]: parts.[[Calendar]] }.
+ return TemporalDate { .year = parts.year, .month = parts.month, .day = parts.day, .calendar = move(parts.calendar) };
}
// 13.36 ParseTemporalDateTimeString ( isoString ), https://tc39.es/proposal-temporal/#sec-temporal-parsetemporaldatetimestring
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp
index af32991535..415aa610fc 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.cpp
@@ -1610,14 +1610,6 @@ bool ISO8601Parser::parse_temporal_instant_string()
return true;
}
-// https://tc39.es/proposal-temporal/#prod-TemporalDateString
-bool ISO8601Parser::parse_temporal_date_string()
-{
- // TemporalDateString :
- // CalendarDateTime
- return parse_calendar_date_time();
-}
-
// https://tc39.es/proposal-temporal/#prod-TemporalDateTimeString
bool ISO8601Parser::parse_temporal_date_time_string()
{
@@ -1745,7 +1737,6 @@ bool ISO8601Parser::parse_temporal_relative_to_string()
#define JS_ENUMERATE_ISO8601_PRODUCTION_PARSERS \
__JS_ENUMERATE(TemporalInstantString, parse_temporal_instant_string) \
- __JS_ENUMERATE(TemporalDateString, parse_temporal_date_string) \
__JS_ENUMERATE(TemporalDateTimeString, parse_temporal_date_time_string) \
__JS_ENUMERATE(TemporalDurationString, parse_temporal_duration_string) \
__JS_ENUMERATE(TemporalMonthDayString, parse_temporal_month_day_string) \
diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h
index 81425f3d89..1010248af7 100644
--- a/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h
+++ b/Userland/Libraries/LibJS/Runtime/Temporal/ISO8601.h
@@ -52,7 +52,6 @@ struct ParseResult {
enum class Production {
TemporalInstantString,
- TemporalDateString,
TemporalDateTimeString,
TemporalDurationString,
TemporalMonthDayString,
@@ -174,7 +173,6 @@ public:
[[nodiscard]] bool parse_duration_date();
[[nodiscard]] bool parse_duration();
[[nodiscard]] bool parse_temporal_instant_string();
- [[nodiscard]] bool parse_temporal_date_string();
[[nodiscard]] bool parse_temporal_date_time_string();
[[nodiscard]] bool parse_temporal_duration_string();
[[nodiscard]] bool parse_temporal_month_day_string();
diff --git a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDate/PlainDate.from.js b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDate/PlainDate.from.js
index 31e6b88c91..b8de3c2a1c 100644
--- a/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDate/PlainDate.from.js
+++ b/Userland/Libraries/LibJS/Tests/builtins/Temporal/PlainDate/PlainDate.from.js
@@ -44,18 +44,18 @@ describe("errors", () => {
}).toThrowWithMessage(TypeError, "null is not a function");
});
- test("invalid date string", () => {
+ test("invalid date time string", () => {
expect(() => {
Temporal.PlainDate.from("foo");
- }).toThrowWithMessage(RangeError, "Invalid date string 'foo'");
+ }).toThrowWithMessage(RangeError, "Invalid date time string 'foo'");
});
test("extended year must not be negative zero", () => {
expect(() => {
Temporal.PlainDate.from("-000000-01-01");
- }).toThrowWithMessage(RangeError, "Invalid date string '-000000-01-01'");
+ }).toThrowWithMessage(RangeError, "Invalid date time string '-000000-01-01'");
expect(() => {
Temporal.PlainDate.from("−000000-01-01"); // U+2212
- }).toThrowWithMessage(RangeError, "Invalid date string '−000000-01-01'");
+ }).toThrowWithMessage(RangeError, "Invalid date time string '−000000-01-01'");
});
});