summary refs log tree commit diff stats
path: root/tests/pragmas/tused.nim
blob: 7616c1215decb919cd4a8f43474f03f0a3af9281 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
discard """
  nimout: '''
compile start
tused.nim(17, 8) Hint: 'tused.echoSub(a: int, b: int)[declared in tused.nim(17, 7)]' is declared but not used [XDeclaredButNotUsed]
compile end'''
  output: "8\n8"
  joinable: false
"""

# not joinable because paths in nimout differ when imported
static:
  echo "compile start"

template implementArithOpsOld(T) =
  proc echoAdd(a, b: T) =
    echo a + b
  proc echoSub(a, b: T) =
    echo a - b

template implementArithOpsNew(T) =
  proc echoAdd(a, b: T) {.used.} =
    echo a + b
  proc echoSub(a, b: T) {.used.} =
    echo a - b

block:
  # should produce warning for the unused 'echoSub'
  implementArithOpsOld(int)
  echoAdd 3, 5

block:
  # no warning produced for the unused 'echoSub'
  implementArithOpsNew(int)
  echoAdd 3, 5

# issue #9896
type
  MyEnum {.used.} = enum
    Val1, Val2, Val3


static:
  echo "compile end"