Skip to content
ZOLO / TE172 Type · error

branches disagree on whether a linear value is consumed

Compiler diagnostic TE172: branches disagree on whether a linear value is consumed.

Why this fires

After an if, match or other branching, a linear value must be in the same state on every branch that continues: consumed on all of them or on none.

let f = File.open(path)?
if verbose {
  f.close()
}                     // TE172: consumed in the `if` branch, not in `else`

Branches that leave (return, break, continue, panic) do not count.

Fix it

Consume it on every branch, or move the consumption after the branches.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en