mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: minor cleanup in find_unreachable_statements_after_noreturn_calls() (#13903)
This commit is contained in:
parent
8c55a9ecd3
commit
0497b885dc
@ -158,8 +158,7 @@ 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)
|
||||||
@ -167,12 +166,10 @@ pub fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []
|
|||||||
}
|
}
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: has_top_return/1 should be called on *already checked* stmts,
|
// Note: has_top_return/1 should be called on *already checked* stmts,
|
||||||
|
Loading…
Reference in New Issue
Block a user