Skip to content

Commit d5ff133

Browse files
authored
checker: relax the "unreachable code after a @[noreturn] call" error to a warning to reduce prototyping friction (#25173)
1 parent 8e9f288 commit d5ff133

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

‎vlib/v/checker/return.v‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ fn (mut c Checker) find_unreachable_statements_after_noreturn_calls(stmts []ast.
328328
if stmt is ast.ExprStmt {
329329
if stmt.expr is ast.CallExpr {
330330
if prev_stmt_was_noreturn_call {
331-
c.error('unreachable code after a @[noreturn] call', stmt.pos)
331+
c.warn('unreachable code after a @[noreturn] call', stmt.pos)
332332
return
333333
}
334334
prev_stmt_was_noreturn_call = stmt.expr.is_noreturn
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: warning: unreachable code after a @[noreturn] call
2+
16 | eprintln('start')
3+
17 | abc()
4+
18 | eprintln('done')
5+
| ~~~~~~~~~~~~~~~~
6+
19 | }
17
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
28
2 | fn another() {
39
3 | eprintln(@FN)
410
4 | for {
511
| ^
612
5 | break
713
6 | }
8-
vlib/v/checker/tests/noreturn_with_non_empty_loop_at_end.vv:18:2: error: unreachable code after a @[noreturn] call
9-
16 | eprintln('start')
10-
17 | abc()
11-
18 | eprintln('done')
12-
| ~~~~~~~~~~~~~~~~
13-
19 | }
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
vlib/v/checker/tests/noreturn_with_return.vv:18:2: warning: unreachable code after a @[noreturn] call
2+
16 | eprintln('start')
3+
17 | abc()
4+
18 | eprintln('done')
5+
| ~~~~~~~~~~~~~~~~
6+
19 | }
17
vlib/v/checker/tests/noreturn_with_return.vv:2:1: error: [noreturn] functions cannot use return statements
28
1 | @[noreturn]
39
2 | fn another() {
@@ -11,9 +17,3 @@ vlib/v/checker/tests/noreturn_with_return.vv:6:2: error: @[noreturn] functions s
1117
| ~~~~~~
1218
7 | }
1319
8 |
14-
vlib/v/checker/tests/noreturn_with_return.vv:18:2: error: unreachable code after a @[noreturn] call
15-
16 | eprintln('start')
16-
17 | abc()
17-
18 | eprintln('done')
18-
| ~~~~~~~~~~~~~~~~
19-
19 | }
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: warning: unreachable code after a @[noreturn] call
2+
13 | eprintln('start')
3+
14 | abc()
4+
15 | eprintln('done')
5+
| ~~~~~~~~~~~~~~~~
6+
16 | }
17
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
28
1 | @[noreturn]
39
2 | fn another() {
410
3 | eprintln(@FN)
511
| ~~~~~~~~~~~~~
612
4 | }
713
5 |
8-
vlib/v/checker/tests/noreturn_without_loop_or_another_noreturn_at_end.vv:15:2: error: unreachable code after a @[noreturn] call
9-
13 | eprintln('start')
10-
14 | abc()
11-
15 | eprintln('done')
12-
| ~~~~~~~~~~~~~~~~
13-
16 | }

0 commit comments

Comments
 (0)