summary refs log tree commit diff stats
path: root/tests/constructors
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2020-03-29 20:31:37 +0300
committerAndreas Rumpf <rumpf_a@web.de>2020-04-01 19:38:44 +0200
commit4f3d309fb0d17e52644029f4c593cd670516655a (patch)
tree8a686632f8b123899e5d75ee3271d6c38de36544 /tests/constructors
parent7b7e42be546889447cb046c1cb2091885d8a19e3 (diff)
downloadNim-4f3d309fb0d17e52644029f4c593cd670516655a.tar.gz
Perform nil checks during object construction and within compiles()
Close https://github.com/nim-lang/Nim/issues/6494
Diffstat (limited to 'tests/constructors')
-rw-r--r--tests/constructors/tinvalid_construction.nim5
1 files changed, 2 insertions, 3 deletions
diff --git a/tests/constructors/tinvalid_construction.nim b/tests/constructors/tinvalid_construction.nim
index eb84c53c8..e6fdbcb85 100644
--- a/tests/constructors/tinvalid_construction.nim
+++ b/tests/constructors/tinvalid_construction.nim
@@ -75,7 +75,7 @@ type
 
 var x = D
 var nilRef: TRefObj
-var notNilRef = TRefObj(x: 20)
+let notNilRef = TRefObjNotNil(x: 20)
 
 proc makeHasNotNils: ref THasNotNils =
   (ref THasNotNils)(a: TRefObj(x: 10),
@@ -102,8 +102,7 @@ reject TObj(a: 10, f: "")       # conflicting fields
 accept TObj(choice: E, e1: TRefObj(x: 10), e2: 10)
 
 accept THasNotNils(a: notNilRef, b: notNilRef, c: nilRef)
-# XXX: the "not nil" logic in the compiler is not strong enough to catch this one yet:
-# reject THasNotNils(a: notNilRef, b: nilRef, c: nilRef)
+reject THasNotNils(a: notNilRef, b: nilRef, c: nilRef)      # `b` shouldn't be nil
 reject THasNotNils(b: notNilRef, c: notNilRef)              # there is a missing not nil field
 reject THasNotNils()                                        # again, missing fields
 accept THasNotNils(a: notNilRef, b: notNilRef)              # it's OK to omit a non-mandatory field