fixes #7637; assignments are not allowed to slice object; minor breaking change

This commit is contained in:
Andreas Rumpf 2018-04-21 21:22:36 +02:00
commit 85ea9593b3
5 changed files with 46 additions and 15 deletions

View file

@ -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])