This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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