diff options
author | Araq <rumpf_a@web.de> | 2018-08-28 12:16:14 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-08-28 12:16:14 +0200 |
commit | dc5851e87373203f5c64b9f15872e2865ab85f3f (patch) | |
tree | ae9260164bc80d4d80d9052da8a52bc8d8866ca2 | |
parent | 96363ecaf3fd9b761d9ea1d7945b3faadee1fcc9 (diff) | |
download | Nim-dc5851e87373203f5c64b9f15872e2865ab85f3f.tar.gz |
added a test to ensure that for-loop-variables cannot be mutated
-rw-r--r-- | tests/varres/tprevent_forloopvar_mutations.nim | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/varres/tprevent_forloopvar_mutations.nim b/tests/varres/tprevent_forloopvar_mutations.nim new file mode 100644 index 000000000..15938bb77 --- /dev/null +++ b/tests/varres/tprevent_forloopvar_mutations.nim @@ -0,0 +1,15 @@ +discard """ + line: 15 + errmsg: "type mismatch: got <int>" + nimout: '''type mismatch: got <int> +but expected one of: +proc inc[T: Ordinal | uint | uint64](x: var T; y = 1) + for a 'var' type a variable needs to be passed, but 'i' is immutable + +expression: inc i +''' +""" + +for i in 0..10: + echo i + inc i |