1
0
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:
yuyi 2022-04-03 16:19:19 +08:00 committed by GitHub
parent 8c55a9ecd3
commit 0497b885dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {
mut prev_stmt_was_noreturn_call := false
for stmt in stmts {
match stmt {
ast.ExprStmt {
if stmt.expr is ast.CallExpr {
if prev_stmt_was_noreturn_call {
c.error('unreachable code after a [noreturn] call', stmt.pos)
return
}
prev_stmt_was_noreturn_call = stmt.expr.is_noreturn
if stmt is ast.ExprStmt {
if stmt.expr is ast.CallExpr {
if prev_stmt_was_noreturn_call {
c.error('unreachable code after a [noreturn] call', stmt.pos)
return
}
prev_stmt_was_noreturn_call = stmt.expr.is_noreturn
}
else {
prev_stmt_was_noreturn_call = false
}
} else {
prev_stmt_was_noreturn_call = false
}
}
}