treorder.nim 551 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. discard """
  2. matrix: "-d:testdef"
  3. output: '''works 34
  4. 34
  5. defined
  6. 3'''
  7. """
  8. {.experimental: "codeReordering".}
  9. {.push callconv: stdcall.}
  10. proc bar(x: T)
  11. proc foo() =
  12. bar(34)
  13. whendep()
  14. proc foo(dummy: int) = echo dummy
  15. proc bar(x: T) =
  16. echo "works ", x
  17. foo(x)
  18. when defined(testdef):
  19. proc whendep() = echo "defined"
  20. else:
  21. proc whendep() = echo "undefined"
  22. foo()
  23. type
  24. T = int
  25. when not declared(goo):
  26. proc goo(my, omy) = echo my
  27. when not declared(goo):
  28. proc goo(my, omy) = echo omy
  29. using
  30. my, omy: int
  31. goo(3, 4)
  32. {.pop.}