summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/guards.nim2
-rw-r--r--tests/notnil/tnotnil4.nim14
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/guards.nim b/compiler/guards.nim
index 813a30014..4cf06fe02 100644
--- a/compiler/guards.nim
+++ b/compiler/guards.nim
@@ -625,7 +625,7 @@ proc factImplies(fact, prop: PNode): TImplication =
     #  == not a or not b == not (a and b)
     let arg = fact.sons[1]
     case arg.getMagic
-    of mIsNil:
+    of mIsNil, mEqRef:
       return ~factImplies(arg, prop)
     of mAnd:
       # not (a and b)  means  not a or not b:
diff --git a/tests/notnil/tnotnil4.nim b/tests/notnil/tnotnil4.nim
new file mode 100644
index 000000000..23968ee48
--- /dev/null
+++ b/tests/notnil/tnotnil4.nim
@@ -0,0 +1,14 @@
+discard ""
+type
+   TObj = ref object
+
+proc check(a: TObj not nil) =
+  echo repr(a)
+
+proc doit() =
+   var x : array[0..1, TObj]
+
+   if x[0] != nil:
+      check(x[0])
+
+doit()
\ No newline at end of file