summary refs log tree commit diff stats
path: root/compiler/semexprs.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-08-21 12:31:55 +0200
committerAraq <rumpf_a@web.de>2015-08-21 21:34:14 +0200
commitbfd2fd67f948f6a5ee8815ee866d55d147f53c73 (patch)
treed03fdbac18566c26c4a9dffd74c270949889a8c9 /compiler/semexprs.nim
parent2733c508ef2681fe8eddfe9c73419ef3226e479d (diff)
downloadNim-bfd2fd67f948f6a5ee8815ee866d55d147f53c73.tar.gz
tuple unpacking works in a non-var/let context
Diffstat (limited to 'compiler/semexprs.nim')
-rw-r--r--compiler/semexprs.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index bb3ec9df0..d6f6e3a2c 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1282,6 +1282,14 @@ proc semAsgn(c: PContext, n: PNode): PNode =
     result = buildOverloadedSubscripts(n.sons[0], getIdent"{}=")
     add(result, n[1])
     return semExprNoType(c, result)
+  of nkPar:
+    if a.len >= 2:
+      # unfortunately we need to rewrite ``(x, y) = foo()`` already here so
+      # that overloading of the assignment operator still works. Usually we
+      # prefer to do these rewritings in transf.nim:
+      return semStmt(c, lowerTupleUnpackingForAsgn(n, c.p.owner))
+    else:
+      a = semExprWithType(c, a, {efLValue})
   else:
     a = semExprWithType(c, a, {efLValue})
   n.sons[0] = a