Skip to content
ZOLO / TE176 Type · error

assignment or shadowing drops a live linear value

Compiler diagnostic TE176: assignment or shadowing drops a live linear value.

Why this fires

An assignment or a let overwrites or shadows a linear value that is still owed, so nothing could ever consume the old value.

let f = open("a")
f = open("b")        // TE176: the first file is lost

A defer over f does not make the assignment safe: it reads the variable when it fires, so it would close the second file and the first would still leak. A shadowing let f = … is accepted when a defer already covers the old f, because the shadow is a new variable and the defer keeps the old one.

Fix it

Consume the old value first, or give the new one another name.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

en