diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 398707bd12..5a04b2b592 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1101,7 +1101,7 @@ proc semForVars(c: PContext, n: PNode; flags: TExprFlags): PNode = iterBase.skipModifier else: skipTypes(iterBase, {tyAlias, tySink, tyOwned}) - var iter = iterType + var iter = skipTypes(iterType, {tyGenericInst}) var iterAfterVarLent = iter.skipTypes({tyGenericInst, tyAlias, tyLent, tyVar}) # n.len == 3 means that there is one for loop variable # and thus no tuple unpacking: diff --git a/tests/iter/t25704.nim b/tests/iter/t25704.nim new file mode 100644 index 0000000000..bab4716c35 --- /dev/null +++ b/tests/iter/t25704.nim @@ -0,0 +1,13 @@ +import std/[sugar, strutils] + +type Res[T] = tuple[a: int, b: string] +iterator test(): Res[string] = + yield (1, "") + +for (i, s) in test(): + static: + echo typeof(i) + echo typeof(s) + let + a: int = i + b: string = s