mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-18 23:11:36 +00:00
fixes #584
This commit is contained in:
@@ -4,7 +4,7 @@ type
|
||||
PMenuItem = ref object
|
||||
|
||||
proc createMenuItem*(menu: PMenu, label: string,
|
||||
action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = nil
|
||||
action: proc (i: PMenuItem, p: pointer) {.cdecl.}) = discard
|
||||
|
||||
var s: PMenu
|
||||
createMenuItem(s, "Go to definition...",
|
||||
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user