summary refs log tree commit diff stats
path: root/tests/destructor
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2019-12-19 11:35:15 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-12-24 17:33:27 +0100
commitd1d017ae859181106c835413c48c46dc036d4c49 (patch)
tree92e2929e5531d1162dd107f3495e04379698bb4d /tests/destructor
parenta7b4b2ed5401325a3a0612e7afd4ecff83d8778f (diff)
downloadNim-d1d017ae859181106c835413c48c46dc036d4c49.tar.gz
fixes #12826
Diffstat (limited to 'tests/destructor')
-rw-r--r--tests/destructor/tcomplexobjconstr.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/destructor/tcomplexobjconstr.nim b/tests/destructor/tcomplexobjconstr.nim
new file mode 100644
index 000000000..23c615783
--- /dev/null
+++ b/tests/destructor/tcomplexobjconstr.nim
@@ -0,0 +1,33 @@
+discard """
+  output: "true"
+  cmd: "nim c --gc:arc $file"
+"""
+
+# bug #12826
+
+type
+  MyObject1* = object of RootObj
+    z*: string
+
+  MyObject2* = object of RootObj
+    x*: float
+    name*: string
+    subobj: MyObject1
+    case flag*: bool
+    of false:
+      more: array[3, MyObject1]
+    of true: y*: float
+
+var x = new(MyObject2)
+assert x of MyObject2
+assert x.subobj of MyObject1
+assert x.more[2] of MyObject1
+assert x.more[2] of RootObj
+
+var y: MyObject2
+assert y of MyObject2
+assert y.subobj of MyObject1
+assert y.more[2] of MyObject1
+assert y.more[2] of RootObj
+
+echo "true"