treorder.nim 529 B

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