summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2020-03-27 20:22:37 +0200
committerAndreas Rumpf <rumpf_a@web.de>2020-04-01 19:38:44 +0200
commit05a0ec4adb5fc5ce1b92ca8693a688586c5b7371 (patch)
treef59e4ebf5ee96964e7a9625cd6d4a28ce038fb8e /tests
parent7652aede41d81b4e7db2c70ffe462c6fb675d078 (diff)
downloadNim-05a0ec4adb5fc5ce1b92ca8693a688586c5b7371.tar.gz
Don't allow 'var x: T' for objects that require initialization
Diffstat (limited to 'tests')
-rw-r--r--tests/constructors/tinvalid_construction.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/constructors/tinvalid_construction.nim b/tests/constructors/tinvalid_construction.nim
index aaf06d4f2..9afee3cd4 100644
--- a/tests/constructors/tinvalid_construction.nim
+++ b/tests/constructors/tinvalid_construction.nim
@@ -125,10 +125,14 @@ accept PartialRequiresInit(a: 10, b: "x")
 accept PartialRequiresInit(a: 20)
 reject PartialRequiresInit(b: "x")
 reject PartialRequiresInit()
+reject:
+  var obj: PartialRequiresInit
 
 accept FullRequiresInit(a: 10, b: 20)
 reject FullRequiresInit(a: 10)
 reject FullRequiresInit(b: 20)
+reject:
+  var obj: FullRequiresInit
 
 accept FullRequiresInitWithParent(a: notNilRef, b: notNilRef, c: notNilRef, e: 10, d: 20)
 accept FullRequiresInitWithParent(a: notNilRef, b: notNilRef, c: nil, e: 10, d: 20)
@@ -136,9 +140,13 @@ reject FullRequiresInitWithParent(a: notNilRef, b: nil, c: nil, e: 10, d: 20) #
 reject FullRequiresInitWithParent(a: notNilRef, b: notNilRef, e: 10, d: 20)   # c should not be missing
 reject FullRequiresInitWithParent(a: notNilRef, b: notNilRef, c: nil, e: 10)  # d should not be missing
 reject FullRequiresInitWithParent()
+reject:
+  var obj: FullRequiresInitWithParent
 
 # this will be accepted, because the false outer branch will be taken and the inner A branch
 accept TNestedChoices()
+accept:
+  var obj: TNestedChoices
 
 # but if we supply a run-time value for the inner branch, the compiler won't be able to prove
 # that the notnil field was initialized