summary refs log tree commit diff stats
path: root/tests/objects
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2017-09-05 01:03:23 +0200
committerAraq <rumpf_a@web.de>2017-09-05 01:03:23 +0200
commit21e22624a21b7ace0ba8e11aab7e7df583aa0c1e (patch)
tree468fb79fbf4324fb994540dd131edbf0ecf09e26 /tests/objects
parent2db96d4f7b2b2698009af7336b3a3dcd61fe7cbd (diff)
downloadNim-21e22624a21b7ace0ba8e11aab7e7df583aa0c1e.tar.gz
fixes #6294
Diffstat (limited to 'tests/objects')
-rw-r--r--tests/objects/tobjconstr.nim38
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/objects/tobjconstr.nim b/tests/objects/tobjconstr.nim
index 226fe98f7..12478f621 100644
--- a/tests/objects/tobjconstr.nim
+++ b/tests/objects/tobjconstr.nim
@@ -8,7 +8,14 @@ discard """
 (k: kindA, a: (x: abc, z: [1, 7, 3]), method: ())
 (k: kindA, a: (x: abc, z: [1, 8, 3]), method: ())
 (k: kindA, a: (x: abc, z: [1, 9, 3]), method: ())
-(k: kindA, a: (x: abc, z: [1, 10, 3]), method: ())'''
+(k: kindA, a: (x: abc, z: [1, 10, 3]), method: ())
+(x: 123)
+(x: 123)
+(z: 89, y: 0, x: 128)
+(y: 678, x: 123)
+(y: 678, x: 123)
+(y: 0, x: 123)
+(y: 678, x: 123)'''
 """
 
 type
@@ -39,3 +46,32 @@ proc main() =
 
 main()
 
+# bug #6294
+type
+  A = object of RootObj
+    x*: int
+  B = object of A
+    y*: int
+  BS = object of B
+  C = object of BS
+    z*: int
+# inherited fields are ignored, so no fields are set
+when true:
+  var
+    o: A
+  o = B(x: 123)
+  echo o
+  o = B(y: 678, x: 123)
+  echo o
+
+# inherited fields are ignored
+echo C(x: 128, z: 89)          # (y: 0, x: 0)
+echo B(y: 678, x: 123)  # (y: 678, x: 0)
+echo B(x: 123, y: 678)  # (y: 678, x: 0)
+
+when true:
+  # correct, both with `var` and `let`;
+  var b=B(x: 123)
+  echo b                  # (y: 0, x: 123)
+  b=B(y: 678, x: 123)
+  echo b                  # (y: 678, x: 123)