mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 17:34:43 +00:00
25 lines
424 B
Nim
25 lines
424 B
Nim
discard """
|
|
output: '''wof!
|
|
wof!'''
|
|
"""
|
|
|
|
# bug #1659
|
|
type Animal = ref object {.inheritable.}
|
|
type Dog = ref object of Animal
|
|
|
|
method say(a: Animal): auto {.base.} = "wat!"
|
|
method say(a: Dog): auto = "wof!"
|
|
|
|
proc saySomething(a: Animal): auto = a.say()
|
|
|
|
|
|
method ec(a: Animal): auto {.base.} = echo "wat!"
|
|
method ec(a: Dog): auto = echo "wof!"
|
|
|
|
proc ech(a: Animal): auto = a.ec()
|
|
|
|
|
|
var a = Dog()
|
|
echo saySomething(a)
|
|
ech a
|