Skip to content

Instantly share code, notes, and snippets.

@Deco
Last active August 29, 2015 14:15
Show Gist options
  • Save Deco/c9d9741a1f67d7d5ca94 to your computer and use it in GitHub Desktop.
Save Deco/c9d9741a1f67d7d5ca94 to your computer and use it in GitHub Desktop.
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