tobj_asgn_dont_slice.nim 439 B

1234567891011121314151617181920212223242526
  1. discard """
  2. matrix: "--mm:refc"
  3. outputsub: '''ObjectAssignmentDefect'''
  4. exitcode: "1"
  5. """
  6. # bug #7637
  7. type
  8. Fruit = object of RootObj
  9. name*: string
  10. Apple = object of Fruit
  11. Pear = object of Fruit
  12. method eat(f: Fruit) {.base.} =
  13. raise newException(Exception, "PURE VIRTUAL CALL")
  14. method eat(f: Apple) =
  15. echo "fruity"
  16. method eat(f: Pear) =
  17. echo "juicy"
  18. let basket = [Apple(name:"a"), Pear(name:"b")]
  19. eat(basket[0])