tinvalid_counter_usage.nim 431 B

123456789101112131415161718192021222324252627
  1. discard """
  2. errormsg: "invalid usage of counter after increment"
  3. line: 21
  4. """
  5. import threadpool
  6. proc f(a: openArray[int]) =
  7. for x in a: echo x
  8. proc f(a: int) = echo a
  9. proc main() =
  10. var a: array[0..30, int]
  11. parallel:
  12. spawn f(a[0..15])
  13. spawn f(a[16..30])
  14. var i = 0
  15. while i <= 30:
  16. inc i
  17. spawn f(a[i])
  18. inc i
  19. #spawn f(a[i+1])
  20. #inc i # inc i, 2 would be correct here
  21. main()