mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix for_in mut var unused warning (#10008)
This commit is contained in:
parent
8c44873674
commit
7c58dfb88b
@ -3211,17 +3211,17 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
|
|||||||
left.info = ident_var_info
|
left.info = ident_var_info
|
||||||
if left_type != 0 {
|
if left_type != 0 {
|
||||||
match mut left.obj {
|
match mut left.obj {
|
||||||
ast.Var { left.obj.typ = left_type }
|
ast.Var {
|
||||||
ast.GlobalField { left.obj.typ = left_type }
|
left.obj.typ = left_type
|
||||||
|
if left.obj.is_auto_deref {
|
||||||
|
left.obj.is_used = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ast.GlobalField {
|
||||||
|
left.obj.typ = left_type
|
||||||
|
}
|
||||||
else {}
|
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 {
|
if is_decl {
|
||||||
full_name := '${left.mod}.$left.name'
|
full_name := '${left.mod}.$left.name'
|
||||||
|
7
vlib/v/checker/tests/no_warning_for_in_mut_var_unused.vv
Normal file
7
vlib/v/checker/tests/no_warning_for_in_mut_var_unused.vv
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fn main() {
|
||||||
|
mut arr := [1, 2, 3]
|
||||||
|
for mut v in arr {
|
||||||
|
v = 2
|
||||||
|
}
|
||||||
|
println(arr)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user