summary refs log tree commit diff stats
path: root/tests/pragmas/tpush.nim
blob: f2779ea70fc73de54c32b1f39dbe7a338566ec5b (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
# test the new pragmas

{.push warnings: off, hints: off.}
proc noWarning() =
  var
    x: int
  echo(x)

{.pop.}

proc WarnMe() =
  var
    x: int
  echo(x)

# bug #11852
proc foo(x: string, y: int, res: int) =
  {.push checks: off}
  var a: ptr char = unsafeAddr(x[y])
  {.pop.}
  if x.len > y:
    doAssert ord(a[]) == 51
  else:
    doAssert x.len + 48 == res

foo("", 0, 48)
foo("abc", 40, 51)