From cc26308044d9098db35e9f985659519b5770eb3b Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 16 Mar 2015 23:16:56 +0100 Subject: [PATCH] fixes #2352 --- build.sh | 0 compiler/sempass2.nim | 2 +- tests/notnil/tnotnil4.nim | 8 +++++++- 3 files changed, 8 insertions(+), 2 deletions(-) mode change 100755 => 100644 build.sh diff --git a/build.sh b/build.sh old mode 100755 new mode 100644 diff --git a/compiler/sempass2.nim b/compiler/sempass2.nim index b8820d85c6..48f54fa6c2 100644 --- a/compiler/sempass2.nim +++ b/compiler/sempass2.nim @@ -460,7 +460,7 @@ proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) = if n.kind == nkAddr: # addr(x[]) can't be proven, but addr(x) can: if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return - elif n.kind == nkSym and n.sym.kind in routineKinds: + elif (n.kind == nkSym and n.sym.kind in routineKinds) or n.kind in procDefs: # 'p' is not nil obviously: return case impliesNotNil(tracked.guards, n) diff --git a/tests/notnil/tnotnil4.nim b/tests/notnil/tnotnil4.nim index 23968ee488..2fa888357f 100644 --- a/tests/notnil/tnotnil4.nim +++ b/tests/notnil/tnotnil4.nim @@ -11,4 +11,10 @@ proc doit() = if x[0] != nil: check(x[0]) -doit() \ No newline at end of file +doit() + +# bug #2352 + +proc p(x: proc() {.noconv.} not nil) = discard +p(proc() {.noconv.} = discard) +# Error: cannot prove 'proc () {.noconv.} = discard ' is not nil