checker: minor cleanup in find_unreachable_statements_after_noreturn_calls() (#13903)

pull/13919/head
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
1 changed files with 8 additions and 11 deletions

View File

@ -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) {
mut prev_stmt_was_noreturn_call := false
for stmt in stmts {
match stmt {
ast.ExprStmt {
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)
@ -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
}
}
else {
} else {
prev_stmt_was_noreturn_call = false
}
}
}
}
// Note: has_top_return/1 should be called on *already checked* stmts,