trefseqsort.nim 423 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. output: '''@[0, 4, 9, 1, 3, 2]
  3. @[0, 1, 2, 3, 9]'''
  4. """
  5. # bug #6724
  6. import algorithm
  7. type
  8. Bar = object
  9. bar: ref seq[int]
  10. Foo = ref Bar
  11. proc test(x: ref Foo) =
  12. x.bar[].del(1)
  13. x.bar[].sort(cmp)
  14. proc main() =
  15. var foo: ref Foo
  16. new(foo)
  17. var s = @[0, 4, 9, 1, 3, 2]
  18. var sr: ref seq[int]
  19. new(sr)
  20. sr[] = s
  21. foo[] = Foo(bar: sr)
  22. echo($foo.bar[])
  23. test(foo)
  24. echo($foo.bar[])
  25. main()