summary refs log tree commit diff stats
path: root/tests/varres/tprevent_forloopvar_mutations.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/varres/tprevent_forloopvar_mutations.nim')
-rw-r--r--tests/varres/tprevent_forloopvar_mutations.nim15
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