diff options
author | Clyybber <darkmine956@gmail.com> | 2020-08-27 15:50:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 15:50:59 +0200 |
commit | fb58066b61b14f4a1d6cdb0f4a8f0a9ea4174d82 (patch) | |
tree | c6e573d9ac221c786ac9e0ca2cf0f186d87a6bbe /tests/template/tparams_gensymed.nim | |
parent | d11933ad998fb0a3eb51bbefbaa53e583aaa3ac1 (diff) | |
download | Nim-fb58066b61b14f4a1d6cdb0f4a8f0a9ea4174d82.tar.gz |
Fix #5691 (#15158)
* Fix #5691 * Cleanup and thoughts * Use scope approach * Seperate defined/declared/declaredInScope magics * Fix declaredInScope * Update spec accordingly
Diffstat (limited to 'tests/template/tparams_gensymed.nim')
-rw-r--r-- | tests/template/tparams_gensymed.nim | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/template/tparams_gensymed.nim b/tests/template/tparams_gensymed.nim index 2a1fda41a..1444667f4 100644 --- a/tests/template/tparams_gensymed.nim +++ b/tests/template/tparams_gensymed.nim @@ -336,3 +336,61 @@ test(hello): var data = 5 hello(data) + +# bug #5691 + +template bar(x: typed) = discard +macro barry(x: typed) = discard + +var a = 0 + +bar: + var a = 10 + +barry: + var a = 20 + +bar: + var b = 10 + +barry: + var b = 20 + +var b = 30 + +# template bar(x: static int) = discard +#You may think that this should work: +# bar((var c = 1; echo "hey"; c)) +# echo c +#But it must not! Since this would be incorrect: +# bar((var b = 3; const c = 1; echo "hey"; c)) +# echo b # <- b wouldn't exist + +discard not (let xx = 1; true) +discard xx + +template barrel(a: typed): untyped = a + +barrel: + var aa* = 1 + var bb = 3 + export bb + +# Test declaredInScope within params +template test1: untyped = + when not declaredInScope(thing): + var thing {.inject.}: int + +proc chunkedReadLoop = + test1 + test1 + +template test2: untyped = + when not not not declaredInScope(thing): + var thing {.inject.}: int + +proc chunkedReadLoop2 = + test2 + test2 + +test1(); test2() |