fix #19304 Borrowing std/times.format causes Error: illformed AST (#20659)

* fix #19304 Borrowing std/times.format causes Error: illformed AST

* follow suggestions

* mitigate for #4121

* improve error message

(cherry picked from commit 2aab03bdfb)
This commit is contained in:
Bung
2023-08-10 16:26:23 +08:00
committed by narimiran
parent 2fa314a89d
commit 665480372e
5 changed files with 80 additions and 28 deletions

7
tests/stdlib/t19304.nim Normal file
View File

@@ -0,0 +1,7 @@
import times
type DjangoDateTime* = distinct DateTime
# proc toTime*(x: DjangoDateTime): Time {.borrow.} # <-- works
proc format*(x: DjangoDateTime, f: TimeFormat,
loc: DateTimeLocale = DefaultLocale): string {.borrow.}