summary refs log tree commit diff stats
path: root/compiler/semtempl.nim
diff options
context:
space:
mode:
authornc-x <neelesh.chandola@outlook.com>2019-05-05 15:52:41 +0530
committerAndreas Rumpf <rumpf_a@web.de>2019-05-05 12:22:41 +0200
commite42c304e4ae623ea8dea9594b531f119bb4142e9 (patch)
tree283c96baa6b4ab443e83cab7e71cde88879122b4 /compiler/semtempl.nim
parent094d71cb6f6fbdedfd43a2bc6c66b227aedf1ddf (diff)
downloadNim-e42c304e4ae623ea8dea9594b531f119bb4142e9.tar.gz
Fix loop tuple unpacking in templates (#11174)
* Fix loop tuple unpacking in templates

* Add test
Diffstat (limited to 'compiler/semtempl.nim')
-rw-r--r--compiler/semtempl.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/semtempl.nim b/compiler/semtempl.nim
index 2854c90ae..3f647cdc1 100644
--- a/compiler/semtempl.nim
+++ b/compiler/semtempl.nim
@@ -372,7 +372,11 @@ proc semTemplBody(c: var TemplCtx, n: PNode): PNode =
     openScope(c)
     n.sons[L-2] = semTemplBody(c, n.sons[L-2])
     for i in countup(0, L - 3):
-      addLocalDecl(c, n.sons[i], skForVar)
+      if n[i].kind == nkVarTuple:
+        for j in 0 ..< sonsLen(n[i])-1:
+          addLocalDecl(c, n[i][j], skForVar)
+      else:
+        addLocalDecl(c, n.sons[i], skForVar)
     openScope(c)
     n.sons[L-1] = semTemplBody(c, n.sons[L-1])
     closeScope(c)