fix https://github.com/timotheecour/Nim/issues/718: CompileTime is not cached apparently (#17940)

This commit is contained in:
Timothee Cour
2021-05-04 23:41:53 -07:00
committed by GitHub
parent 5762b1d75c
commit 00bb3c779e

View File

@@ -21,14 +21,17 @@ block:
template main() =
# xxx merge more const related tests here
const ct = CompileTime
# refs https://github.com/timotheecour/Nim/issues/718, apparently `CompileTime`
# isn't cached, which seems surprising.
block:
const
a = """
Version $1|
Compiled at: $2, $3
""" % [NimVersion & spaces(44-len(NimVersion)), CompileDate, CompileTime]
""" % [NimVersion & spaces(44-len(NimVersion)), CompileDate, ct]
let b = $a
doAssert CompileTime in b, $(b, CompileTime)
doAssert ct in b, $(b, ct)
doAssert NimVersion in b
static: main()