Expand description
§leo-errors
This directory contains the code for the Errors for all the Leo crates.
The errors are inspired by rust
in a few different ways:
- Each error has its own unique code.
- Error codes will never be changed upon a stable release.
- Meaning outdated errors will just deprecated.
- In addition we had a unique identifier to let you know where the compiler found the error.
The purpose of these errors is such that searching an error in the documentation, or online for help, becomes easier.
§Common
The common section of this crate contains a few sub files:
- Backtraced Error: Which contains the information needed to create a backtraceable error for Leo.
- Formatted Error: Which contains the information needed to create a formatted error for Leo.
- Macros: Which contains the logic to make creating errors easy through a DSL. It also figures out the error codes for each error via a top down method. Meaning all new errors should be added to the bottom of the file. You can specify whether an error is formatted or backtraced through a decorator above a function name, where the formatted ones require a Span as an argument by default. The body takes any additional arguments you want provided to the function, the message, and the optional help message for the error. The additional arguments are just specified to implement traits to avoid as many type conversions in other Leo crates.
- Span: Which contains the span object used throughout the other Leo crates (with the exception of the Input crate see more below).
- Traits: Which contains the common traits in errors to make defining errors easier.
§Error Types
These are the different kinds of errors that are made in this crate. Note that if you want more information about the errors please check the crates documentation or the Error Index. All errors here with the exception of SnarkVM Errors have a 037 prefixed to their error codes.
§ASG
The errors for the leo-asg
crate. Its error codes will range from 3_000-3_999 and be prefixed with the characters ASG
.
§AST
The errors for the leo-ast
crate. Its error codes will range from 2_000-2_999 and be prefixed with the characters AST
.
§CLI
The errors for the leo-lang
crate. Its error codes will range from 7_000-7_999 and be prefixed with the characters CLI
.
§Compiler
The errors for the leo-compiler
crate. Its error codes will range from 6_000-6_999 and be prefixed with the characters CMP
.
§Import
The errors for the leo-imports
crate. Its error codes will range from 4_000-4_999 and be prefixed with the characters IMP
.
§Loop Unrolling
The errors for loop unrolling in the leo-passes
crate. Its error codes will range from 9_000-9_999 and be prefixed with the characters LUN
.
§Package
The errors for the leo-package
crate. Its error codes will range from 5_000-5_999 and be prefixed with the characters PAK
.
§Parser
The errors for the leo-parser
crate. Its error codes will range from 0-999 and be prefixed with the characters PAR
.
§SnarkVM
The errors from SnarkVM that bubble up into Leo in some situations. For right now, they have an exit code of 1. When SnarkVM implements better error codes and messages, we can bubble them up.
§Utils
The errors related to dependency retrieval in the utils
crate. Its error codes will range from 10_000-10_999 and be prefixed with the characters DEP
.
Modules§
- ast_
errors - This module contains the AST error definitions.
- backtraced
- This module contains a backtraced error and its methods.
- cli_
errors - This module contains the CLI error definitions.
- common 🔒
- Contains the common functionalities for defining errors.
- compiler_
errors - This module contains the Compiler error definitions.
- emitter 🔒
- Contains traits and types for channels through which errors go.
- errors 🔒
- Contains the errors and warnings for the Leo language.
- flattener_
errors - This module contains the Flattener error definitions.
- formatted
- This module contains a formatted error and its methods.
- loop_
unroller_ errors - macros
- This module contains the macros for making errors easily.
- package_
errors - This module contains the Package error definitions.
- parser_
errors - This module contains the Parser error definitions.
- parser_
warnings - This module contains the Parser warning definitions.
- static_
analyzer_ error - This module contains the static analysis error definitions.
- static_
analyzer_ warning - traits
- This module contains traits for making errors easily.
- type_
checker_ error - This module contains the Input error definitions.
- type_
checker_ warning - util_
errors - This module contains the Input error definitions.
Macros§
- create_
messages - A macro that given an enum, exit code mask, error code string prefix, and error methods generated through a DSL creates and generates errors with a unique error code.
Structs§
- Backtraced
- Backtraced compiler output type
undefined value
x
–> file.leo: 2:8 = help: Initialize a variablex
first. - Buffer
- A buffer of
T
s. - Buffer
Emitter - An
Emitter
that collects into a list. - Formatted
- Formatted compiler error type
undefined value
x
–> file.leo: 2:8 | 2 | let a = x; | ^ | = help: Initialize a variablex
first. Makes use of the same fields as a BacktracedError. - Handler
- A handler deals with errors and other compiler output.
- Handler
Inner - Interpreter
Halt - Represents the interpreter halting, which should not be considered an actual runtime error.
- Stderr
Emitter - A trivial
Emitter
using the standard error.
Enums§
- AstError
- AstError enum that represents all the errors for the
leo-ast
crate. - CliError
- CliError enum that represents all the errors for the
leo-lang
crate. - Compiler
Error - CompilerError enum that represents all the errors for the
leo-compiler
crate. - Flatten
Error - CliError enum that represents all the errors for the
leo-lang
crate. - LeoError
- The LeoError type that contains all sub error types. This allows a unified error type throughout the Leo crates.
- LeoWarning
- The LeoWarning type that contains all sub warning types. This allows a unified warning type throughout the Leo crates.
- Loop
Unroller Error - LoopUnrollerError enum that represents all the errors for the loop unrolling errors in the
leo-loop_unroller
crate. - Package
Error - PackageError enum that represents all the errors for the
leo-package
crate. - Parser
Error - ParserError enum that represents all the errors for the
leo-parser
crate. - Parser
Warning - ParserWarning enum that represents all the warnings for the
leo-parser
crate. - Static
Analyzer Error - StaticAnalyzer enum that represents all the errors for static analysis.
- Static
Analyzer Warning - ParserWarning enum that represents all the warnings for static analysis
- Type
Checker Error - Type
Checker Warning - ParserWarning enum that represents all the warnings for the
leo-parser
crate. - Util
Error - InputError enum that represents all the errors for the
utils
crate.
Traits§
- Emitter
- Types that are sinks for compiler errors.
- LeoMessage
Code - MessageCode trait that all Errors should implement.
Type Aliases§
- ErrBuffer
- A buffer of
LeoError
s. - Result
- A global result type for all Leo crates, that defaults the errors to be a LeoError.
- Warning
Buffer - A buffer of
LeoWarning
s.