summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-01-14 15:03:53 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-01-14 15:03:53 +0100
commit2e62090ec3c58023034d3fc21d8660731dfc3d42 (patch)
treed74d9177b3c2f149b96d3c1f977df5acb3412032 /tests
parent522f8f1cc60649b982f231d85ca0d1ac34f358d5 (diff)
parentf838c1baa48a22ef74f431d9b691af179d1c632d (diff)
downloadNim-2e62090ec3c58023034d3fc21d8660731dfc3d42.tar.gz
Merge pull request #3500 from nanoant/patch/fix-3498-generic-args-in-tmpl
fixes #3498
Diffstat (limited to 'tests')
-rw-r--r--tests/generics/tgenerictmpl.nim25
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/generics/tgenerictmpl.nim b/tests/generics/tgenerictmpl.nim
index a749e6570..c71ce4e2e 100644
--- a/tests/generics/tgenerictmpl.nim
+++ b/tests/generics/tgenerictmpl.nim
@@ -1,12 +1,21 @@
+discard """
+  output: '''0
+123'''
+"""
 
-template tmp[T](x: var seq[T]) =
-  #var yz: T  # XXX doesn't work yet
-  x = @[1, 2, 3]
+# bug #3498
+
+template defaultOf[T](t: T): expr = (var d: T; d)
+
+echo defaultOf(1) #<- excpected 0
 
-macro tmp2[T](x: var seq[T]): stmt =
-  nil
+# assignment using template
+
+template tassign[T](x: var seq[T]) =
+  x = @[1, 2, 3]
 
 var y: seq[int]
-tmp(y)
-tmp(y)
-echo y.repr
+tassign(y) #<- x is expected = @[1, 2, 3]
+tassign(y)
+
+echo y[0], y[1], y[2]