fixes explicit globals in macros (#21502)

This commit is contained in:
ringabout 2023-03-13 03:03:46 +08:00 • committed by GitHub
commit b2c1dcbbc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -643,3 +643,16 @@ const b = block:
doAssert a == @[@[0, 1, 2], @[0, 1, 2], @[0, 1, 2]]
doAssert b == @[@[0, 1, 2], @[0, 1, 2], @[0, 1, 2]]
macro m1(s: string): int =
var ProcID {.global, compileTime.}: int
inc(ProcID)
result = newLit(ProcID)
proc macroGlobal =
doAssert m1("Macro argument") == 1
doAssert m1("Macro argument") == 2
doAssert m1("Macro argument") == 3
static: macroGlobal()
macroGlobal()