added a test to ensure that for-loop-variables cannot be mutated
This commit is contained in:
parent
96363ecaf3
commit
dc5851e873
1 changed files with 15 additions and 0 deletions
15
tests/varres/tprevent_forloopvar_mutations.nim
Normal file
15
tests/varres/tprevent_forloopvar_mutations.nim
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue