fixes #3993
This commit is contained in:
parent
dee5e63f62
commit
96ddf6972d
2 changed files with 16 additions and 1 deletions
|
|
@ -525,7 +525,8 @@ proc notNilCheck(tracked: PEffects, n: PNode, paramType: PType) =
|
||||||
# addr(x[]) can't be proven, but addr(x) can:
|
# addr(x[]) can't be proven, but addr(x) can:
|
||||||
if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return
|
if not containsNode(n, {nkDerefExpr, nkHiddenDeref}): return
|
||||||
elif (n.kind == nkSym and n.sym.kind in routineKinds) or
|
elif (n.kind == nkSym and n.sym.kind in routineKinds) or
|
||||||
n.kind in procDefs+{nkObjConstr, nkBracket, nkClosure}:
|
(n.kind in procDefs+{nkObjConstr, nkBracket, nkClosure}) or
|
||||||
|
(n.kind in nkCallKinds and n[0].kind == nkSym and n[0].sym.magic == mArrToSeq):
|
||||||
# 'p' is not nil obviously:
|
# 'p' is not nil obviously:
|
||||||
return
|
return
|
||||||
case impliesNotNil(tracked.guards, n)
|
case impliesNotNil(tracked.guards, n)
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,17 @@ proc parse(cts: CTS, jn: JsonNode) =
|
||||||
|
|
||||||
proc p(x: proc(){.closure.} not nil) = discard
|
proc p(x: proc(){.closure.} not nil) = discard
|
||||||
p(proc(){.closure.} = discard)
|
p(proc(){.closure.} = discard)
|
||||||
|
|
||||||
|
# bug #3993
|
||||||
|
|
||||||
|
type
|
||||||
|
List[T] = seq[T] not nil
|
||||||
|
|
||||||
|
proc `^^`[T](v: T, lst: List[T]): List[T] =
|
||||||
|
result = @[v]
|
||||||
|
result.add(lst)
|
||||||
|
|
||||||
|
proc Nil[T](): List[T] = @[]
|
||||||
|
|
||||||
|
when isMainModule:
|
||||||
|
let lst = 1 ^^ 2 ^^ Nil[int]()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue