blob: b7c7a811d1b37754c4a2c03b28b81edc70363239 (
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 """
errormsg: "cannot prove 'variable' is not nil"
line: 31
"""
# bug #584
# Testprogram for 'not nil' check
const testWithResult = true
type
A = object
B = object
C = object
a: ref A
b: ref B
proc testNotNil(c: ref C not nil) =
discard
when testWithResult:
proc testNotNilOnResult(): ref C =
new(result)
#result.testNotNil() # Here 'not nil' can't be proved
var variable: ref C
new(variable)
variable.testNotNil() # Here 'not nil' is proved
when testWithResult:
discard testNotNilOnResult()
|