fixes #584
This commit is contained in:
parent
cf544f6a85
commit
2b9311e9f1
5 changed files with 86 additions and 27 deletions
35
tests/notnil/tnotnil3.nim
Normal file
35
tests/notnil/tnotnil3.nim
Normal file
|
|
@ -0,0 +1,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()
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue