checker: minor cleanup in find_unreachable_statements_after_noreturn_calls() (#13903)
parent
8c55a9ecd3
commit
0497b885dc
|
@ -158,19 +158,16 @@ pub fn (mut c Checker) return_stmt(mut node ast.Return) {
|
||||||
pub fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []ast.Stmt) {
|
pub fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []ast.Stmt) {
|
||||||
mut prev_stmt_was_noreturn_call := false
|
mut prev_stmt_was_noreturn_call := false
|
||||||
for stmt in stmts {
|
for stmt in stmts {
|
||||||
match stmt {
|
if stmt is ast.ExprStmt {
|
||||||
ast.ExprStmt {
|
if stmt.expr is ast.CallExpr {
|
||||||
if stmt.expr is ast.CallExpr {
|
if prev_stmt_was_noreturn_call {
|
||||||
if prev_stmt_was_noreturn_call {
|
c.error('unreachable code after a [noreturn] call', stmt.pos)
|
||||||
c.error('unreachable code after a [noreturn] call', stmt.pos)
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
prev_stmt_was_noreturn_call = stmt.expr.is_noreturn
|
|
||||||
}
|
}
|
||||||
|
prev_stmt_was_noreturn_call = stmt.expr.is_noreturn
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
prev_stmt_was_noreturn_call = false
|
prev_stmt_was_noreturn_call = false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue