tbug1081.nim 741 B

1234567891011121314151617181920212223242526272829303132333435
  1. discard """
  2. output: '''1
  3. 0
  4. 0
  5. 0
  6. x = ['a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6'] and y = ['a', 'b', 'c', '0', '1', '2', '3', '4', '5', '6']'''
  7. """
  8. proc `1/1`() = echo(1 div 1)
  9. template `1/2`() = echo(1 div 2)
  10. var `1/3` = 1 div 4
  11. `1/3` = 1 div 3 # oops, 1/3!=1/4
  12. let `1/4` = 1 div 4
  13. `1/1`()
  14. `1/2`()
  15. echo `1/3`
  16. echo `1/4`
  17. # bug #6422
  18. proc toCharArray1(N : static[int], s: string): array[N, char] =
  19. doAssert s.len <= N
  20. let x = cast[ptr array[N, char]](s.cstring)
  21. x[]
  22. proc toCharArray2(N : static[int], s: string): array[N, char] =
  23. doAssert s.len <= N
  24. let x = cast[ptr array[N, char]](s.cstring)
  25. result = x[]
  26. let x = toCharArray1(10, "abc0123456")
  27. let y = toCharArray2(10, "abc0123456")
  28. echo "x = ", $x, " and y = ", $y