diff options
-rw-r--r-- | compiler/semgnrc.nim | 7 | ||||
-rw-r--r-- | tests/tuples/tfortupleunpack.nim | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/compiler/semgnrc.nim b/compiler/semgnrc.nim index 5972f3b55..2810fca9e 100644 --- a/compiler/semgnrc.nim +++ b/compiler/semgnrc.nim @@ -352,7 +352,12 @@ proc semGenericStmt(c: PContext, n: PNode, openScope(c) n.sons[L - 2] = semGenericStmt(c, n.sons[L-2], flags, ctx) for i in countup(0, L - 3): - addTempDecl(c, n.sons[i], skForVar) + if (n.sons[i].kind == nkVarTuple): + for s in n.sons[i]: + if (s.kind == nkIdent): + addTempDecl(c,s,skForVar) + else: + addTempDecl(c, n.sons[i], skForVar) openScope(c) n.sons[L - 1] = semGenericStmt(c, n.sons[L-1], flags, ctx) closeScope(c) diff --git a/tests/tuples/tfortupleunpack.nim b/tests/tuples/tfortupleunpack.nim index 56cf30ebc..9aeb7c5d6 100644 --- a/tests/tuples/tfortupleunpack.nim +++ b/tests/tuples/tfortupleunpack.nim @@ -8,6 +8,7 @@ output: ''' 113283 @[(88, 99, 11), (88, 99, 11)] @[(7, 6, -28), (7, 6, -28)] +12 ''' """ @@ -36,4 +37,7 @@ for i, (a, b, c) in x.mpairs: c = -28 echo x - +proc test[n]() = + for (a,b) in @[(1,2)]: + echo a,b +test[string]() |