Skip to content

Commit

Permalink
improve
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Oct 10, 2024
1 parent 2af62e9 commit fc69bd9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions vlib/v/checker/return.v
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,9 @@ fn (mut c Checker) check_noreturn_fn_decl(mut node ast.FnDecl) {
if uses_return_stmt(node.stmts) {
c.error('[noreturn] functions cannot use return statements', node.pos)
}
mut pos := node.pos
mut is_valid_end_of_noreturn_fn := false
if node.stmts.len != 0 {
mut is_valid_end_of_noreturn_fn := false
last_stmt := node.stmts.last()
match last_stmt {
ast.ExprStmt {
Expand All @@ -392,12 +393,12 @@ fn (mut c Checker) check_noreturn_fn_decl(mut node ast.FnDecl) {
else {}
}
if !is_valid_end_of_noreturn_fn {
c.error('@[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop',
last_stmt.pos)
pos = last_stmt.pos
}
} else {
}
if !is_valid_end_of_noreturn_fn {
c.error('@[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop',
node.pos)
pos)
}
}

Expand Down

0 comments on commit fc69bd9

Please sign in to comment.