summary refs log blame commit diff stats
path: root/tests/objects/tobj_asgn_dont_slice.nim
blob: 866b5aeccbd1ce9f40e67a2ddfb2bc7a02da3f44 (plain) (tree)























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