texplicitcmp.nim 536 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. output: '''[1 2 3 ]
  3. [1 2 3 ]
  4. [1 2 3 ]'''
  5. """
  6. # bug #297
  7. import json, tables, algorithm
  8. proc outp(a: openArray[int]) =
  9. stdout.write "["
  10. for i in a: stdout.write($i & " ")
  11. stdout.write "]\n"
  12. proc works() =
  13. var f = @[3, 2, 1]
  14. sort(f, system.cmp[int])
  15. outp(f)
  16. proc weird(json_params: Table) =
  17. var f = @[3, 2, 1]
  18. # The following line doesn't compile: type mismatch. Why?
  19. sort(f, system.cmp[int])
  20. outp(f)
  21. var t = @[3, 2, 1]
  22. sort(t, system.cmp[int])
  23. outp(t)
  24. works()
  25. weird(initTable[string, JsonNode]())