summary refs log tree commit diff stats
path: root/tests/template
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-02-04 21:00:07 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-02-04 21:00:07 +0100
commitabaf5d0bdba3a4908eec65199867831141ed8a55 (patch)
tree03d31212e6de436c0c0b2b5d141830478d03e2f0 /tests/template
parent95d8558f0cdbb3324985210e51fb0c8bb66b99a9 (diff)
downloadNim-abaf5d0bdba3a4908eec65199867831141ed8a55.tar.gz
fixes #5285
Diffstat (limited to 'tests/template')
-rw-r--r--tests/template/tgensymregression.nim21
-rw-r--r--tests/template/typedescids.nim2
2 files changed, 22 insertions, 1 deletions
diff --git a/tests/template/tgensymregression.nim b/tests/template/tgensymregression.nim
new file mode 100644
index 000000000..e73ff258d
--- /dev/null
+++ b/tests/template/tgensymregression.nim
@@ -0,0 +1,21 @@
+
+template mathPerComponent(op: untyped): untyped =
+  proc op*[N,T](v,u: array[N,T]): array[N,T] {.inline.} =
+    for i in 0 ..< len(result):
+      result[i] = `*`(v[i], u[i])
+
+mathPerComponent(`***`)
+# bug #5285
+when true:
+  if isMainModule:
+    var v1: array[3, float64]
+    var v2: array[3, float64]
+    echo repr(v1 *** v2)
+
+
+proc foo(): void =
+  var v1: array[4, float64]
+  var v2: array[4, float64]
+  echo repr(v1 *** v2)
+
+foo()
diff --git a/tests/template/typedescids.nim b/tests/template/typedescids.nim
index ebed49b17..1df2f69fb 100644
--- a/tests/template/typedescids.nim
+++ b/tests/template/typedescids.nim
@@ -6,7 +6,7 @@ discard """
 
 var i {.compileTime.} = 2
 
-template defineId*(t: typedesc): stmt =
+template defineId*(t: typedesc) =
   const id {.genSym.} = i
   static: inc(i)
   proc idFor*(T: typedesc[t]): int {.inline, raises: [].} = id