checker: fix for_in mut var unused warning (#10008)

pull/10022/head
yuyi 2021-05-05 19:11:32 +08:00 committed by GitHub
parent 8c44873674
commit 7c58dfb88b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View File

@ -3211,17 +3211,17 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
left.info = ident_var_info
if left_type != 0 {
match mut left.obj {
ast.Var { left.obj.typ = left_type }
ast.GlobalField { left.obj.typ = left_type }
ast.Var {
left.obj.typ = left_type
if left.obj.is_auto_deref {
left.obj.is_used = true
}
}
ast.GlobalField {
left.obj.typ = left_type
}
else {}
}
/*
if left.obj is ast.Var as v {
v.typ = left_type
} else if left.obj is ast.GlobalDecl as v {
v.typ = left_type
}
*/
}
if is_decl {
full_name := '${left.mod}.$left.name'

View File

@ -0,0 +1,7 @@
fn main() {
mut arr := [1, 2, 3]
for mut v in arr {
v = 2
}
println(arr)
}