summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/semstmts.nim5
-rw-r--r--tests/errmsgs/t17460.nim4
2 files changed, 6 insertions, 3 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 5a0968ba5..d62ad8305 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -930,7 +930,10 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode =
   if iterAfterVarLent.kind != tyTuple or n.len == 3:
     if n.len == 3:
       if n[0].kind == nkVarTuple:
-        if n[0].len-1 != iterAfterVarLent.len:
+        if iterAfterVarLent.kind != tyTuple:
+          return localErrorNode(c, n, n[0].info, errTupleUnpackingTupleExpected %
+              [typeToString(n[1].typ, preferDesc)])
+        elif n[0].len-1 != iterAfterVarLent.len:
           return localErrorNode(c, n, n[0].info, errWrongNumberOfVariables)
 
         for i in 0..<n[0].len-1:
diff --git a/tests/errmsgs/t17460.nim b/tests/errmsgs/t17460.nim
index e377bc48a..bb8e21198 100644
--- a/tests/errmsgs/t17460.nim
+++ b/tests/errmsgs/t17460.nim
@@ -1,6 +1,6 @@
 discard """
   cmd: "nim check $options $file"
-  errormsg: "wrong number of variables"
+  errormsg: "tuple expected for tuple unpacking, but got 'array[0..2, int]'"
 """
 
 iterator xclusters*[T](a: openArray[T]; s: static[int]): array[s, T] {.inline.} =
@@ -16,4 +16,4 @@ proc m =
   for (i, j, k) in xclusters([1, 2, 3, 4, 5], 3):
     echo i, j, k
 
-m()
\ No newline at end of file
+m()