Skip to content
TE100 · Type · error

Undefined variable

The name is not declared in any enclosing scope. The compiler attaches a "did you mean?" suggestion when a similar name exists.

Why this fires

The name is not declared in any enclosing scope. The most common causes are:

  • A typo in the name (prnt instead of print).
  • A missing use for a module symbol.
  • A name only declared inside a sibling scope that has already ended.
  • The declaration is below the use site in top-level code (Zolo resolves top-level items eagerly, so this is rare — but it can happen with conditional use blocks).
fn main() {
    prnt("hello")
//  ^^^^ error: undefined variable `prnt` — did you mean `print`?
}

Fix it

1. Correct the spelling

The compiler attaches a Levenshtein "did you mean?" suggestion when a similar name exists nearby. Trust it for typos.

2. Import the symbol

If the name comes from another module:

use std::math::{sin, cos}

fn main() {
    print(sin(0.5))
}

3. Move the declaration

If the name was declared in an inner scope that already closed:

if condition {
    let x = compute()
}
print(x)   // x went out of scope at the `}` above

Lift the binding out:

let x = if condition { compute() } else { default_value() }
print(x)

See also

  • TE104 — no such method on a value (different lookup mechanism).
  • TE102 — struct field not found.
enespt-br