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

cgen: fix a bug (deleting a map key while iterating on the same map) detected by -d debug_realloc

This commit is contained in:
Delyan Angelov 2021-03-16 09:20:45 +02:00
parent 93df560cf9
commit 506561c792
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED

View File

@ -405,11 +405,16 @@ fn (mut g Gen) comp_for(node ast.CompFor) {
g.stmts(node.stmts)
i++
g.writeln('}')
//
mut delete_keys := []string{}
for key, _ in g.comptime_var_type_map {
if key.starts_with(node.val_var) {
g.comptime_var_type_map.delete(key)
delete_keys << key
}
}
for key in delete_keys {
g.comptime_var_type_map.delete(key)
}
}
} else if node.kind == .fields {
// TODO add fields