X0011 -- Undefined Variable¶
Reserved code:
X0011is not emitted by the current compiler. An undefined name is reported as T001. This page is kept for continuity.
A name was used that is not defined in the current scope.
Bad Example¶
fn bad() -> Int {
return x; // x is not defined
}
Fix¶
Declare the variable, add it as a parameter, or import it from another module:
fn fixed(x: Int) -> Int {
return x;
}
Notes¶
- Inside methods, bare method calls (
init()) automatically resolve toself.init(). - Module-level
pub constnames are registered before function bodies, so forward references work.