This commit is contained in:
Araq
2015-10-22 10:24:46 +02:00
parent 3f24a7ff3e
commit d93507fd2e
4 changed files with 51 additions and 4 deletions

View File

@@ -0,0 +1,35 @@
discard """
output: '''Foo
Bar'''
"""
# bug #3338
type
Base[T] = Foo[T] | Bar[T]
Foo[T] = ref object
x: T
Bar[T] = ref object
x: T
proc test[T](ks: Foo[T], x, y: T): T =
echo("Foo")
return x + y + ks.x
proc test[T](ks: Bar[T], x, y: T): T =
echo("Bar")
return x
proc add[T](ksa: Base[T]) =
var test = ksa.test(5, 10)
ksa.x = test
var t1 = Foo[int32]()
t1.add()
doAssert t1.x == 15
var t2 = Bar[int32]()
t2.add()
doAssert t2.x == 5