Skip to content
Prismio docs
ImplementedPrismio 0.1.0

Unreachable code

Fix Prismio statements that can never execute after return or another terminator.

Last verified

Implemented. Available in the audited Prismio 0.1.0 compiler. Pre-1.0 syntax may still change.

Meaning

A statement follows control flow that cannot continue, most commonly an unconditional return in the same block.

Other terminators include break and continue in their valid loop positions, or control flow proven never to fall through. Rejecting unreachable statements prevents dead ownership actions and stale code from hiding behind a terminator.

Why it happens

A return was inserted above existing code, branches were simplified, or a copied statement was placed after an unconditional loop transfer.

Invalid code

prismio
import std.io

fn main() -> Int {
    return 0
    println("never")
}

Correct code

prismio
import std.io

fn main() -> Int {
    println("before")
    return 0
}

Common fixes

Delete or move the unreachable statement, or restructure the branch so control can reach it.

Do not weaken a correct early return solely to retain dead code. If the statement belongs on another path, place it before the terminator or inside the appropriate conditional branch.