Clear iterate slice-variables after iteration

This commit is contained in:
Nigel Tao committed 2021-01-19 21:59:29 +11:00
1 parent 92cda94f66
commit c9221e7c27
2 files changed
+26

No files matched your search

+4
View File
@@ -480,6 +480,10 @@ func (g *gen) writeStatementIterate(b *buffer, n *a.Iterate, depth uint32) error
unroll = 1
}
}
for _, o := range assigns {
name := o.AsAssign().LHS().Ident().Str(g.tm)
b.printf("%s%s.len = 0;\n", vPrefix, name)
}
b.writes("}\n")
return nil