summary refs log tree commit diff stats
path: root/tests/msgs/twarningaserror.nim
blob: 6f7b7609567bf4055d94b2b895ee54bd0e2ce928 (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
discard """
  joinable: false
"""

#[
tests: hintAsError, warningAsError
]#

template fn1 =
  {.hintAsError[ConvFromXtoItselfNotNeeded]:on.}
  proc fn(a: string) = discard a.string
  {.hintAsError[ConvFromXtoItselfNotNeeded]:off.}

template fn2 =
  {.hintAsError[ConvFromXtoItselfNotNeeded]:on.}
  proc fn(a: string) = discard a
  {.hintAsError[ConvFromXtoItselfNotNeeded]:off.}

template gn1 =
  {.warningAsError[ProveInit]:on.}
  proc fn(): var int = discard
  discard fn()
  {.warningAsError[ProveInit]:off.}

template gn2 =
  {.warningAsError[ProveInit]:on.}
  proc fn(): int = discard
  discard fn()
  {.warningAsError[ProveInit]:off.}

doAssert not compiles(fn1())
doAssert compiles(fn2())

doAssert not compiles(gn1())
doAssert compiles(gn2())