its_full_of_procs.nim 677 B

123456789101112131415161718192021222324252627282930
  1. import unicode, sequtils
  2. # This example shows that idetools returns proc as signature for everything
  3. # which can be called. While a clever person would use the second column to
  4. # differentiate between procs, methods and others, why does the output contain
  5. # incorrect information?
  6. type
  7. TThing = object of TObject
  8. TUnit = object of TThing
  9. x: int
  10. method collide(a, b: TThing) {.inline.} =
  11. quit "to override!"
  12. method collide(a: TThing, b: TUnit) {.inline.} =
  13. echo "1"
  14. method collide(a: TUnit, b: TThing) {.inline.} =
  15. echo "2"
  16. var
  17. a, b: TUnit
  18. let
  19. input = readFile("its_full_of_procs.nim")
  20. letters = toSeq(runes(string(input)))
  21. collide(a, b) # output: 2