1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

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

This commit is contained in:
Delyan Angelov 2021-08-31 15:14:23 +03:00
parent e72af5e2ee
commit f68bdb7805

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)