tprevent_forloopvar_mutations.nim 382 B

1234567891011121314151617
  1. discard """
  2. errormsg: "type mismatch: got <int>"
  3. nimout: '''tprevent_forloopvar_mutations.nim(16, 3) Error: type mismatch: got <int>
  4. but expected one of:
  5. proc inc[T: Ordinal](x: var T; y: int = 1)
  6. first type mismatch at position: 1
  7. required type for x: var T: Ordinal
  8. but expression 'i' is immutable, not 'var'
  9. expression: inc i
  10. '''
  11. """
  12. for i in 0..10:
  13. echo i
  14. inc i