Skip to content

Commit 734bb00

Browse files
authored
checker: cleanup check_non_expr_branch_last_stmt (#23330)
1 parent c786482 commit 734bb00

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

vlib/v/checker/if.v

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -690,14 +690,12 @@ fn (mut c Checker) smartcast_if_conds(mut node ast.Expr, mut scope ast.Scope, co
690690
}
691691

692692
fn (mut c Checker) check_non_expr_branch_last_stmt(stmts []ast.Stmt) {
693-
if stmts.len > 0 {
694-
last_stmt := stmts.last()
695-
if last_stmt is ast.ExprStmt {
696-
if last_stmt.expr is ast.InfixExpr {
697-
if last_stmt.expr.op !in [.left_shift, .right_shift, .unsigned_right_shift, .arrow] {
698-
c.error('expression evaluated but not used', last_stmt.pos)
699-
}
700-
}
701-
}
693+
if stmts.len == 0 {
694+
return
695+
}
696+
last_stmt := stmts.last()
697+
if last_stmt is ast.ExprStmt && (last_stmt.expr is ast.InfixExpr
698+
&& last_stmt.expr.op !in [.left_shift, .right_shift, .unsigned_right_shift, .arrow]) {
699+
c.error('expression evaluated but not used', last_stmt.pos)
702700
}
703701
}

0 commit comments

Comments
 (0)