Skip to content

Commit

Permalink
parser: fix invalid warning 'unused' for mut var in if/match cond(fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
shove70 committed Nov 11, 2023
1 parent cd337e2 commit 4105948
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vlib/v/parser/expr.v
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ fn (mut p Parser) check_expr(precedence int) !ast.Expr {
.key_mut, .key_shared, .key_atomic, .key_static, .key_volatile {
ident := p.ident(ast.Language.v)
node = ident
if p.peek_tok.kind != .assign && (p.inside_if_cond || p.inside_match) {
p.mark_var_as_used(ident.name)
}
p.add_defer_var(ident)
p.is_stmt_ident = is_stmt_ident
}
Expand Down

0 comments on commit 4105948

Please sign in to comment.