summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-10-22 10:24:46 +0200
committerAraq <rumpf_a@web.de>2015-10-22 10:24:46 +0200
commitd93507fd2e88fe1cffb69b8f0cf50a6670bfbecc (patch)
tree89faafcf65bc98173089db45865dc971ddb2fc19 /tests
parent3f24a7ff3ea45253b496ab08c2bdecb838f0419d (diff)
downloadNim-d93507fd2e88fe1cffb69b8f0cf50a6670bfbecc.tar.gz
fixes #3338
Diffstat (limited to 'tests')
-rw-r--r--tests/metatype/ttypeor.nim35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/metatype/ttypeor.nim b/tests/metatype/ttypeor.nim
new file mode 100644
index 000000000..f5acce772
--- /dev/null
+++ b/tests/metatype/ttypeor.nim
@@ -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