MZ1001
MZ1001 · Parse Error · ERROR
Unknown Variable
A variable was used before it was declared, or it does not exist in the current scope.

Cause

The identifier referenced in the expression has not been declared in the current scope or any enclosing scope. This can happen if the variable name is misspelled, if the variable was declared in a different block, or if the variable was never declared at all.

Examples

Example 1

Problem:

echo(total)
# total was never declared

The variable 'total' is used but never declared.

Fix:

Declare the variable before using it: total = 0

Example 2

Problem:

if true {
    y = 20
}
echo(y)
# y is out of scope

The variable 'y' was declared inside an if block and is not accessible outside it.

Fix:

Declare the variable outside the block before the if statement.

Hint

Check the spelling of the variable name. Mozhi is case-sensitive.

Suggestion

Declare the variable with name = value before using it.

Related