fixes #7637; assignments are not allowed to slice object; minor breaking change
This commit is contained in:
parent
14046d975d
commit
85ea9593b3
5 changed files with 46 additions and 15 deletions
24
tests/objects/tobj_asgn_dont_slice.nim
Normal file
24
tests/objects/tobj_asgn_dont_slice.nim
Normal 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])
|
||||
Loading…
Add table
Add a link
Reference in a new issue