tprevent_forloopvar_mutations.nim 338 B

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