diff options
author | Araq <rumpf_a@web.de> | 2017-09-05 01:03:23 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2017-09-05 01:03:23 +0200 |
commit | 21e22624a21b7ace0ba8e11aab7e7df583aa0c1e (patch) | |
tree | 468fb79fbf4324fb994540dd131edbf0ecf09e26 /tests/objects | |
parent | 2db96d4f7b2b2698009af7336b3a3dcd61fe7cbd (diff) | |
download | Nim-21e22624a21b7ace0ba8e11aab7e7df583aa0c1e.tar.gz |
fixes #6294
Diffstat (limited to 'tests/objects')
-rw-r--r-- | tests/objects/tobjconstr.nim | 38 |
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) |