summary refs log tree commit diff stats
path: root/tests/objects/tobj_asgn_dont_slice.nim
blob: 2e36b65a3cdd44874ef20d13a4ec8f41d75e74cf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
discard """
  outputsub: '''ObjectAssignmentDefect'''
  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])