tused.nim 727 B

123456789101112131415161718192021222324252627282930313233343536
  1. discard """
  2. nimout: '''
  3. compile start
  4. tused.nim(15, 8) Hint: 'tused.echoSub(a: int, b: int)[declared in tused.nim(15, 7)]' is declared but not used [XDeclaredButNotUsed]
  5. compile end'''
  6. output: "8\n8"
  7. """
  8. static:
  9. echo "compile start"
  10. template implementArithOpsOld(T) =
  11. proc echoAdd(a, b: T) =
  12. echo a + b
  13. proc echoSub(a, b: T) =
  14. echo a - b
  15. template implementArithOpsNew(T) =
  16. proc echoAdd(a, b: T) {.used.} =
  17. echo a + b
  18. proc echoSub(a, b: T) {.used.} =
  19. echo a - b
  20. block:
  21. # should produce warning for the unused 'echoSub'
  22. implementArithOpsOld(int)
  23. echoAdd 3, 5
  24. block:
  25. # no warning produced for the unused 'echoSub'
  26. implementArithOpsNew(int)
  27. echoAdd 3, 5
  28. static:
  29. echo "compile end"