proper order of initialization for .global. variables

This commit is contained in:
Zahary Karadjov 2012-04-10 20:53:44 +03:00
commit a64f03230a
7 changed files with 62 additions and 3 deletions

15
tests/run/globalaux.nim Normal file
View file

@ -0,0 +1,15 @@
type
TObj*[T] = object
val*: T
var
totalGlobals* = 0
proc makeObj[T](x: T): TObj[T] =
totalGlobals += 1
result.val = x
proc globalInstance*[T]: var TObj[T] =
var g {.global.} = when T is int: makeObj(10) else: makeObj("hello")
result = g