mirror of
https://github.com/vlang/v.git
synced 2025-09-24 04:48:28 -04:00
checker: relax the "unreachable code after a @[noreturn] call" error to a warning to reduce prototyping friction (#25173)
This commit is contained in:
parent
8e9f2880a0
commit
d5ff13335f
@ -328,7 +328,7 @@ fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []ast.
|
|||||||
if stmt is ast.ExprStmt {
|
if stmt is 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.warn('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
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: warning: unreachable code after a @[noreturn] call
|
||||||
|
16 | eprintln('start')
|
||||||
|
17 | abc()
|
||||||
|
18 | eprintln('done')
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
19 | }
|
||||||
vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:4:6: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop
|
vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:4:6: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop
|
||||||
2 | fn another() {
|
2 | fn another() {
|
||||||
3 | eprintln(@FN)
|
3 | eprintln(@FN)
|
||||||
@ -5,9 +11,3 @@ vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:4:6: error: @[noretu
|
|||||||
| ^
|
| ^
|
||||||
5 | break
|
5 | break
|
||||||
6 | }
|
6 | }
|
||||||
vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: error: unreachable code after a @[noreturn] call
|
|
||||||
16 | eprintln('start')
|
|
||||||
17 | abc()
|
|
||||||
18 | eprintln('done')
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
19 | }
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
vlib/v/checker/tests/noreturn_with_return.vv:18:2: warning: unreachable code after a @[noreturn] call
|
||||||
|
16 | eprintln('start')
|
||||||
|
17 | abc()
|
||||||
|
18 | eprintln('done')
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
19 | }
|
||||||
vlib/v/checker/tests/noreturn_with_return.vv:2:1: error: [noreturn] functions cannot use return statements
|
vlib/v/checker/tests/noreturn_with_return.vv:2:1: error: [noreturn] functions cannot use return statements
|
||||||
1 | @[noreturn]
|
1 | @[noreturn]
|
||||||
2 | fn another() {
|
2 | fn another() {
|
||||||
@ -11,9 +17,3 @@ vlib/v/checker/tests/noreturn_with_return.vv:6:2: error: @[noreturn] functions s
|
|||||||
| ~~~~~~
|
| ~~~~~~
|
||||||
7 | }
|
7 | }
|
||||||
8 |
|
8 |
|
||||||
vlib/v/checker/tests/noreturn_with_return.vv:18:2: error: unreachable code after a @[noreturn] call
|
|
||||||
16 | eprintln('start')
|
|
||||||
17 | abc()
|
|
||||||
18 | eprintln('done')
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
19 | }
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: warning: unreachable code after a @[noreturn] call
|
||||||
|
13 | eprintln('start')
|
||||||
|
14 | abc()
|
||||||
|
15 | eprintln('done')
|
||||||
|
| ~~~~~~~~~~~~~~~~
|
||||||
|
16 | }
|
||||||
vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:3:2: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop
|
vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:3:2: error: @[noreturn] functions should end with a call to another @[noreturn] function, or with an infinite `for {}` loop
|
||||||
1 | @[noreturn]
|
1 | @[noreturn]
|
||||||
2 | fn another() {
|
2 | fn another() {
|
||||||
@ -5,9 +11,3 @@ vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:3:2: er
|
|||||||
| ~~~~~~~~~~~~~
|
| ~~~~~~~~~~~~~
|
||||||
4 | }
|
4 | }
|
||||||
5 |
|
5 |
|
||||||
vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: error: unreachable code after a @[noreturn] call
|
|
||||||
13 | eprintln('start')
|
|
||||||
14 | abc()
|
|
||||||
15 | eprintln('done')
|
|
||||||
| ~~~~~~~~~~~~~~~~
|
|
||||||
16 | }
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user