Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
proc incval(x: string; y: string): string =
"completely unrelated"
proc test(): tuple[incval: proc(); getval: proc():int] =
var val = 0
proc incval() =
inc val
proc getval(): int =
val
result = (incval: incval, getval: getval) # <--- error here
# closures.nim(15, 13) Error: type mismatch:
# got (tuple[incval: None, getval: proc (): int{.closure, gcsafe, locks: 0.}])
# but expected 'tuple[incval: proc (){.closure.}, getval: proc (): int{.closure.}]'
var ret = test()
echo ret.getval()
ret.incval()
ret.incval()
ret.incval()
echo ret.getval()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment