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:
parent
e72af5e2ee
commit
f68bdb7805
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user