Overview
This guide covers common errors you might encounter while programming in Leo, along with their solutions. Leo’s error codes follow the formatE{CATEGORY}{CODE}, where categories include PAR (parser), AST, TYC (type checker), and CMP (compiler).
Parser Errors (PAR)
Parser errors occur during the lexing and parsing phase.Unexpected Token
Error:Unexpected EOF
Error:Invalid Address Literal
Error:aleo1).
Solution:
Type Checker Errors (TYC)
Type checker errors occur during semantic analysis.Type Mismatch
Error:Unknown Symbol
Error:Incorrect Number of Arguments
Error:Cannot Assign to Const
Error:Invalid Assignment Target
Error:Compiler Errors (CMP)
Compiler errors occur during the compilation and code generation phase.Import Not Found
Error:Program Name Mismatch
Error:Imported Program Not Found
Error:program.json.
Solution:
Illegal Static Member Assignment
Error:Common Runtime Issues
Assertion Failures
Error:assert statement evaluated to false.
Solution:
Arithmetic Overflow
Error: Proof generation fails due to overflow. Cause: Arithmetic operation exceeds type bounds. Solution:Arithmetic Underflow
Error: Proof generation fails due to underflow. Cause: Subtraction results in negative value for unsigned types. Solution:Mapping Errors
Mapping Get Failure
Error: Transaction fails when accessing non-existent key. Cause: UsingMapping::get on a key that doesn’t exist.
Solution:
Mapping Access Outside Finalizer
Error:Build and CLI Issues
Command Not Found
Error:Build Fails
Error:Outdated Leo Version
Error:Development Environment
Rust Version Issues
Error:Formatting Issues
Error:Debugging Strategies
Enable Verbose Output
Check Generated Aleo Code
- How Leo compiles to Aleo instructions
- Register allocation
- Optimization results
Use Assertions for Debugging
Simplify Complex Functions
Break down complex functions into smaller pieces:Getting Help
Check Documentation
Language Reference
Complete syntax reference
Examples
Working example programs
Community Support
- Discord: Join the Aleo Discord
- GitHub Discussions: Leo Discussions
- GitHub Issues: Report bugs
File a Bug Report
When reporting issues, include:- Leo version (
leo --version) - Operating system
- Complete error message
- Minimal reproducible example
- Expected vs actual behavior
Related Resources
FAQ
Frequently asked questions
Contributing
Help improve Leo