Learn how to debug Leo programs, interpret error messages, and resolve common issues during development.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/provablehq/leo/llms.txt
Use this file to discover all available pages before exploring further.
Error Messages
Leo provides structured error messages with unique error codes to help diagnose issues quickly.Error Code Format
Leo errors follow the format:E{PREFIX}037{CODE}
- Prefix: Indicates the error category
- 037: Fixed identifier for Leo errors
- Code: Unique error number within the category
EPAR0370042 is parser error 42
Error Categories
Leo errors are organized by compiler component:Parser Errors (PAR: 0-999)
Parser Errors (PAR: 0-999)
Errors during source code parsing:Common causes:
- Syntax errors
- Invalid token sequences
- Missing semicolons or braces
AST Errors (AST: 2000-2999)
AST Errors (AST: 2000-2999)
Errors in abstract syntax tree construction:Common causes:
- Type mismatches
- Invalid type annotations
- Malformed AST nodes
Compiler Errors (CMP: 6000-6999)
Compiler Errors (CMP: 6000-6999)
Errors during compilation:Common causes:
- Type checking failures
- Undefined variables
- Invalid operations
Package Errors (PAK: 5000-5999)
Package Errors (PAK: 5000-5999)
Errors related to project structure and dependencies:Common causes:
- Missing
program.json - Invalid manifest format
- Dependency resolution failures
Understanding Error Output
Leo error messages include:- Error code: Unique identifier for the error type
- Error message: Human-readable description
- Source location: File, line, and column
- Code snippet: Context showing where the error occurred
- Help text: Suggestions for fixing the issue (when available)
Debugging Techniques
Using Console Output
Leo supports console functions for debugging (development only):Type Checking
Explicitly specify types to catch errors early:Assertions for Debugging
Use assertions to validate assumptions:Incremental Testing
Break complex functions into testable parts:Common Issues
Type Mismatch Errors
Undefined Variable
Invalid Program Name
Cause
Program name violates naming rules:
- Starts with underscore or number
- Contains invalid characters
- Contains the word “aleo” in the name
Circular Dependency
Mapping Access Outside Finalize
Build and Compilation Issues
Check Syntax
Run syntax validation without full compilation:Clean Build
Remove build artifacts and rebuild:Verbose Output
Enable detailed compiler output:Compiler Version
Verify you’re using the correct Leo version:Development Workflow
Rust-level Debugging
For compiler development, use Rust debugging tools:Running Tests with Output
Using Clippy
Run the linter to catch common issues:Format Checking
Ensure code is properly formatted:Leo uses nightly Rust formatter. Install with:
Performance Debugging
Circuit Size
Monitor generated circuit size:Loop Unrolling
Be aware of loop unrolling impact:Memory Usage
From the compiler’s performance guidelines:- Pre-allocate collections with
with_capacitywhen size is known - Avoid unnecessary clones
- Use references when ownership isn’t needed
- Minimize intermediate allocations
Getting Help
Search Error Codes
Look up error codes in documentation:Community Resources
- Discord: discord.gg/aleo
- GitHub Issues: github.com/ProvableHQ/leo/issues
- Forum: forum.aleo.org
Filing Bug Reports
When filing issues, include:- Leo version (
leo --version) - Minimal reproducible example
- Full error message with code
- Expected vs actual behavior
- Operating system
Next Steps
- Learn about package management to handle dependencies
- Review best practices for writing robust code
- Explore testing strategies for comprehensive coverage