summary refs log tree commit diff stats
path: root/drnim/tests/tsetlen_invalidates.nim
blob: f3e59574461238619515b9d27c3a32b588a3b33f (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
discard """
  nimout: '''tsetlen_invalidates.nim(12, 10) Warning: BEGIN [User]
tsetlen_invalidates.nim(18, 12) Warning: cannot prove: 0 <= len(a) + -1; counter example: a`1.len -> 0
a.len -> 1 [IndexCheck]
tsetlen_invalidates.nim(26, 10) Warning: END [User]
'''
  cmd: "drnim $file"
  action: "compile"
"""

{.push staticBoundChecks: defined(nimDrNim).}
{.warning: "BEGIN".}

proc p() =
  var a = newSeq[int](3)
  if a.len > 0:
    a.setLen 0
    echo a[0]

  if a.len > 0:
    echo a[0]

{.pop.}

p()
{.warning: "END".}