import times

var ifo = getGMTime(getTime())

Warning: Cannot prove that 'ifo' is initialized. This will become a compile time error in the future. [ProveInit]

I've looked over the code in times.nim, but getGMTime just returns tmToTimeInfo(), which just returns a TimeInfo(...) constructor. How can it not prove that was an initialization? Am I doing something wrong?

2017-03-09 22:39:37
I know that to fix the error, you can put everything into a main proc and call main, but I can't tell you much more than that. 2017-03-09 23:31:57

Actually, I've thought about this problem some more (I had the same thing happen to me when I was trying to make a SDL2 event global variable). I think it happens because the variable is in global scope, yet is initialized during run time. Thus, the compiler can't guarantee it is initialized before it is accessed, hence the warning?

That is the only explanation I can think of, but I'm pretty far away from being an expert, so there's that .

2017-03-10 23:35:18

I've hit this issue a few times. I'd also like to know the explanation of this behaviour since it left me completely puzzled.

@nucky9 Thanks for the tip with main proc, it helped me work around this pesky warning. However, I'd still like to know what exactly I did wrong.

2017-03-18 19:40:24