import times var ifo = getGMTime(getTime()) echo(ifo)
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?
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 .
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.