mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
28 lines
417 B
Nim
28 lines
417 B
Nim
discard """
|
|
output: '''wohoo
|
|
baz'''
|
|
"""
|
|
|
|
# Test to ensure the popular 'ref T' syntax works everywhere
|
|
|
|
type
|
|
Foo = object
|
|
a, b: int
|
|
s: string
|
|
|
|
FooBar = object of RootObj
|
|
n, m: string
|
|
Baz = object of FooBar
|
|
|
|
proc invoke(a: ref Baz) =
|
|
echo "baz"
|
|
|
|
# check object construction:
|
|
let x = (ref Foo)(a: 0, b: 45, s: "wohoo")
|
|
echo x.s
|
|
|
|
var y: ref FooBar = (ref Baz)(n: "n", m: "m")
|
|
|
|
invoke((ref Baz)(y))
|
|
|