diff options
author | Araq <rumpf_a@web.de> | 2015-04-10 13:45:12 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-04-10 14:03:49 +0200 |
commit | 49471440eb4ca9d6afd1aed23c1581c0b8d262f1 (patch) | |
tree | 6d4d030896cf1d2d9027d5f899202ba19785080e /tests/overload/tstmtoverload.nim | |
parent | 10c1d7f519ad2dc5b971449a21052c50ef98757f (diff) | |
download | Nim-49471440eb4ca9d6afd1aed23c1581c0b8d262f1.tar.gz |
fixes #2481
Diffstat (limited to 'tests/overload/tstmtoverload.nim')
-rw-r--r-- | tests/overload/tstmtoverload.nim | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/overload/tstmtoverload.nim b/tests/overload/tstmtoverload.nim new file mode 100644 index 000000000..f1944b637 --- /dev/null +++ b/tests/overload/tstmtoverload.nim @@ -0,0 +1,38 @@ + +# bug #2481 +import math + +template test(loopCount: int, extraI: int, testBody: stmt): stmt = + block: + for i in 0..loopCount-1: + testBody + echo "done extraI=", extraI + +template test(loopCount: int, extraF: float, testBody: stmt): stmt = + block: + test(loopCount, round(extraF), testBody) + +template test(loopCount: int, testBody: stmt): stmt = + block: + test(loopCount, 0, testBody) + echo "done extraI passed 0" + +when isMainModule: + var + loops = 0 + + test 0, 0: + loops += 1 + echo "test 0 complete, loops=", loops + + test 1, 1.0: + loops += 1 + echo "test 1.0 complete, loops=", loops + + when true: + # when true we get the following compile time error: + # b.nim(35, 6) Error: expression 'loops += 1' has no type (or is ambiguous) + loops = 0 + test 2: + loops += 1 + echo "test no extra complete, loops=", loops |