v.markused.walker: support `for x in struct{}` iterators

pull/11357/head
Delyan Angelov 2021-08-31 15:14:23 +03:00
parent e72af5e2ee
commit f68bdb7805
1 changed files with 7 additions and 0 deletions

View File

@ -110,6 +110,13 @@ pub fn (mut w Walker) stmt(node ast.Stmt) {
if node.kind == .map {
w.table.used_maps++
}
if node.kind == .struct_ {
// the .next() method of the struct will be used for iteration:
cond_type_sym := w.table.get_type_symbol(node.cond_type)
if next_fn := cond_type_sym.find_method('next') {
w.fn_decl(mut &ast.FnDecl(next_fn.source_fn))
}
}
}
ast.ForStmt {
w.expr(node.cond)