Fix regression in std/times (#22155)

* Add simple test case

Just so the regression doesn't happen again

* Specify initDateTime is gcsafe in the forward declarations
This commit is contained in:
Jake Leahy
2023-06-26 23:07:42 +10:00
committed by GitHub
parent 3e44d5742f
commit 43a3de9077
2 changed files with 6 additions and 2 deletions

View File

@@ -1529,11 +1529,11 @@ proc getClockStr*(dt = now()): string {.rtl, extern: "nt$1", tags: [TimeEffect].
proc initDateTime*(weekday: WeekDay, isoweek: IsoWeekRange, isoyear: IsoYear,
hour: HourRange, minute: MinuteRange, second: SecondRange,
nanosecond: NanosecondRange,
zone: Timezone = local()): DateTime {.raises: [], tags: [], since: (1, 5).}
zone: Timezone = local()): DateTime {.gcsafe, raises: [], tags: [], since: (1, 5).}
proc initDateTime*(weekday: WeekDay, isoweek: IsoWeekRange, isoyear: IsoYear,
hour: HourRange, minute: MinuteRange, second: SecondRange,
zone: Timezone = local()): DateTime {.raises: [], tags: [], since: (1, 5).}
zone: Timezone = local()): DateTime {.gcsafe, raises: [], tags: [], since: (1, 5).}
#
# TimeFormat

View File

@@ -766,3 +766,7 @@ block: # ttimes
check dt.format("GGGG") == "2023"
check dt.format("dddd 'KW'V GGGG") == "Thursday KW1 2023"
block: # Can be used inside gcsafe proc
proc test(): DateTime {.gcsafe.} =
result = "1970".parse("yyyy")
doAssert test().year == 1970