Why this fires
The name is not declared in any enclosing scope. The most common causes are:
- A typo in the name (
prntinstead ofprint). - A missing
usefor 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
useblocks).
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)