tripon[github]

diagnostic codes / Warnings

E0602 unreachable-code

Code after a `return` can never run.

E0602unreachable-codeunreachable after earlier return/branch
severitywarn
bandWarnings
in the v0 bootstrapreserved — not emitted yet
explainralt explain E0602

The warning table reserves a code for statements after an unconditional `return` in the same block. It is a warning because a `return` can be deliberately early while older code is kept for reference.

Not emitted by the v0 bootstrap

Not emitted in v0. The statement after `return 0;` is checked and silently accepted; nothing reports it.

What it looks like

e0602.tp
use tier core;

fn main() -> i32 {
    return 0;
    print_str("never");
}
ralt check e0602.tp
echo $?
0

What to do

  • Delete the statement, or move it above the `return`.
  • If the `return` was meant to be conditional, it needs an `if` around it.

Why the code exists

Unreachable code in a language with no exceptions is always a mistake or a leftover. It is cheap to detect and cheap to fix, so it stays at warning severity.

What ralt explain says

ralt explain E0602
E0602
severity: warn
name: unreachable-code
hint: unreachable after earlier return/branch

Related