fixes #3338
This commit is contained in:
parent
3f24a7ff3e
commit
d93507fd2e
4 changed files with 51 additions and 4 deletions
35
tests/metatype/ttypeor.nim
Normal file
35
tests/metatype/ttypeor.nim
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue