summary refs log tree commit diff stats
path: root/tests/distinct/tdistinct.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/distinct/tdistinct.nim')
-rw-r--r--tests/distinct/tdistinct.nim26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/distinct/tdistinct.nim b/tests/distinct/tdistinct.nim
index 8ec083020..b6ba7aa99 100644
--- a/tests/distinct/tdistinct.nim
+++ b/tests/distinct/tdistinct.nim
@@ -159,7 +159,7 @@ block: #17322
 
 type Foo = distinct string
 
-template main() =
+proc main() = # proc instead of template because of MCS/UFCS.
   # xxx put everything here to test under RT + VM
   block: # bug #12282
     block:
@@ -199,5 +199,29 @@ template main() =
       var c: B
 
 
+  block: # bug #9423
+    block:
+      type Foo = seq[int]
+      type Foo2 = distinct Foo
+      template fn() =
+        var a = Foo2(@[1])
+        a.Foo.add 2
+        doAssert a.Foo == @[1, 2]
+      fn()
+
+    block:
+      type Stack[T] = distinct seq[T]
+      proc newStack[T](): Stack[T] =
+        Stack[T](newSeq[T]())
+      proc push[T](stack: var Stack[T], elem: T) =
+        seq[T](stack).add(elem)
+      proc len[T](stack: Stack[T]): int =
+        seq[T](stack).len
+      proc fn() = 
+        var stack = newStack[int]()
+        stack.push(5)
+        doAssert stack.len == 1
+      fn()
+
 static: main()
 main()