The following sample shows a typical construct in my programs, where I first define a init() proc and then a shortcut initFoo() to simplify var declarations:
type
Something = object
name: string not nil
proc init(X: var Something) =
X.name = "Default"
proc initSomething(): Something =
result.init() # Cannot prove that 'result' is initialized
proc test() =
var s = initSomething()
echo s.name
when isMainModule: test()
The line marked with the comment shows a compiler warning:
prove.nim(9, 2) Warning: Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]
I don't understand where the problem is. Can somebody explain why this pattern will become a compile time error in the future?