tused.nim 820 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. discard """
  2. nimout: '''
  3. compile start
  4. tused.nim(17, 8) Hint: 'echoSub' is declared but not used [XDeclaredButNotUsed]
  5. compile end'''
  6. output: "8\n8"
  7. joinable: false
  8. """
  9. # not joinable because paths in nimout differ when imported
  10. static:
  11. echo "compile start"
  12. template implementArithOpsOld(T) =
  13. proc echoAdd(a, b: T) =
  14. echo a + b
  15. proc echoSub(a, b: T) =
  16. echo a - b
  17. template implementArithOpsNew(T) =
  18. proc echoAdd(a, b: T) {.used.} =
  19. echo a + b
  20. proc echoSub(a, b: T) {.used.} =
  21. echo a - b
  22. block:
  23. # should produce warning for the unused 'echoSub'
  24. implementArithOpsOld(int)
  25. echoAdd 3, 5
  26. block:
  27. # no warning produced for the unused 'echoSub'
  28. implementArithOpsNew(int)
  29. echoAdd 3, 5
  30. # issue #9896
  31. type
  32. MyEnum {.used.} = enum
  33. Val1, Val2, Val3
  34. static:
  35. echo "compile end"