t12037.nim 521 B

12345678910111213141516171819
  1. discard """
  2. cmd: '''nim c --newruntime $file'''
  3. output: '''
  4. showing original type, length, and contents seq[int] 1 @[42]
  5. copy length and contents 1 @[42]
  6. '''
  7. """
  8. proc test() =
  9. var sq1 = @[42]
  10. echo "showing original type, length, and contents ", sq1.typeof, " ", sq1.len, " ", sq1
  11. doAssert cast[int](sq1[0].unsafeAddr) != 0
  12. var sq2 = sq1 # copy of original
  13. echo "copy length and contents ", sq2.len, " ", sq2
  14. doAssert cast[int](sq2[0].unsafeAddr) != 0
  15. doAssert cast[int](sq1[0].unsafeAddr) != 0
  16. test()