You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to add a trailing = to proc declarations for the functions I importcpp from std::vector, if I want to use runnableExamples. But if I do so, I get this warning if the return type is var T.
Warning: Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]
Example
Save below file to a t.nim and run nim doc --backend:cpp t.nim (requires the latest nim devel version).
{.pushheader: "<vector>".}
typeVector*[T] {.importcpp: "std::vector".} =objectprocnewVector*[T](): Vector[T] {.importcpp: "std::vector<'*0>()", constructor.}
procadd*[T](v: varVector[T], elem: T){.importcpp: "#.push_back(#)".}
procfirst*[T](v: Vector[T]): var T {.importcpp: "front".} =## Return the reference to the first element of the Vector.#### This has an alias proc `front`.#### https://en.cppreference.com/w/cpp/container/vector/front
runnableExamples:
var
v =newVector[int]()
v.add(100)
doAssert v.first() ==100
{.pop.}
Current Output
The doc gets generated fine, but we get this warning:
/home/kmodi/sandbox/nim/bug_reports/cannot_prove_result_uninit/t.nim(11, 3) Warning: Cannot prove that 'result' is initialized. This will become a compile time error in the future. [ProveInit]
$ nim -v
Nim Compiler Version 1.3.3 [Linux: amd64]
Compiled at 2020-05-11
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: 86669ef5b4c9711d81e961c2f68a05aa4f4d9ece
active boot switches: -d:release
The text was updated successfully, but these errors were encountered:
kaushalmodi
changed the title
Getting "Warning: Cannot prove that 'result' is initialized" for an importcpp'd proc
Getting "Warning: Cannot prove that 'result' is initialized" for an importcpp'd proc with var T return type
May 12, 2020
I need to add a trailing
=
to proc declarations for the functions I importcpp from std::vector, if I want to userunnableExamples
. But if I do so, I get this warning if the return type isvar T
.Example
Save below file to a
t.nim
and runnim doc --backend:cpp t.nim
(requires the latest nim devel version).Current Output
The doc gets generated fine, but we get this warning:
Expected Output
No ProveInit warning
Additional Information
/cc @timotheecour
The text was updated successfully, but these errors were encountered: