diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-04-21 21:22:36 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-04-21 21:22:36 +0200 |
commit | 85ea9593b38351e69fedac61ff0c2b958bac4b7f (patch) | |
tree | b991e735138440769ae7e995172b3ab4be438d4d /tests/objects/tobj_asgn_dont_slice.nim | |
parent | 14046d975dd0c5a5195dea7d6bdcb3daa8e69eca (diff) | |
download | Nim-85ea9593b38351e69fedac61ff0c2b958bac4b7f.tar.gz |
fixes #7637; assignments are not allowed to slice object; minor breaking change
Diffstat (limited to 'tests/objects/tobj_asgn_dont_slice.nim')
-rw-r--r-- | tests/objects/tobj_asgn_dont_slice.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/objects/tobj_asgn_dont_slice.nim b/tests/objects/tobj_asgn_dont_slice.nim new file mode 100644 index 000000000..866b5aecc --- /dev/null +++ b/tests/objects/tobj_asgn_dont_slice.nim @@ -0,0 +1,24 @@ +discard """ + outputsub: '''ObjectAssignmentError''' + exitcode: "1" +""" + +# bug #7637 +type + Fruit = object of RootObj + name*: string + Apple = object of Fruit + Pear = object of Fruit + +method eat(f: Fruit) {.base.} = + raise newException(Exception, "PURE VIRTUAL CALL") + +method eat(f: Apple) = + echo "fruity" + +method eat(f: Pear) = + echo "juicy" + +let basket = [Apple(name:"a"), Pear(name:"b")] + +eat(basket[0]) |