diff options
author | Yuriy Glukhov <yglukhov@users.noreply.github.com> | 2018-11-24 11:50:48 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-11-24 10:50:48 +0100 |
commit | 410fd1deae95ecc9fd146fc2c8e6cc0cd24bfee7 (patch) | |
tree | 9d862b5a09bf0747c96b80d381eb9133a2f30008 /tests/iter | |
parent | 47d0582ebf1d70188dfa3771d01929c593df709e (diff) | |
download | Nim-410fd1deae95ecc9fd146fc2c8e6cc0cd24bfee7.tar.gz |
Fixes 9716 [backport] (#9790)
* reuse temporary variable * fixes #9716 [backport] * Declare local vars in safer place
Diffstat (limited to 'tests/iter')
-rw-r--r-- | tests/iter/tyieldintry.nim | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/iter/tyieldintry.nim b/tests/iter/tyieldintry.nim index ee2790e54..32eef494e 100644 --- a/tests/iter/tyieldintry.nim +++ b/tests/iter/tyieldintry.nim @@ -403,7 +403,7 @@ block: # yield in blockexpr test(it, 1, 2, 3) -block: #8851 +block: #8851 type Foo = ref object of RootObj template someFoo(): Foo = @@ -454,5 +454,18 @@ block: #9694 - yield in ObjConstr test(it, 1, 2) +block: #9716 + iterator it(): int {.closure.} = + var a = 0 + for i in 1 .. 3: + var a: int # Make sure the "local" var is reset + var b: string # ditto + yield 1 + a += 5 + b &= "hello" + doAssert(a == 5) + doAssert(b == "hello") + test(it, 1, 1, 1) + echo "ok" |