leo_errors/errors/parser/
parser_errors.rsuse crate::create_messages;
use std::fmt::{Debug, Display};
create_messages!(
ParserError,
code_mask: 0000i32,
code_prefix: "PAR",
@formatted
unexpected_token {
args: (message: impl Display),
msg: message,
help: None,
}
@formatted
invalid_address_lit {
args: (token: impl Display),
msg: format!("invalid address literal: '{token}'"),
help: None,
}
@formatted
invalid_import_list {
args: (),
msg: "Cannot import empty list",
help: None,
}
@formatted
unexpected_eof {
args: (),
msg: "unexpected EOF",
help: None,
}
@formatted
unexpected_whitespace {
args: (left: impl Display, right: impl Display),
msg: format!("Unexpected white space between terms {left} and {right}"),
help: None,
}
@formatted
unexpected {
args: (found: impl Display, expected: impl Display),
msg: format!("expected {expected} -- found '{found}'"),
help: None,
}
@formatted
mixed_commas_and_semicolons {
args: (),
msg: "Cannot mix use of commas and semi-colons for struct member variable declarations.",
help: None,
}
@formatted
unexpected_ident {
args: (found: impl Display, expected: &[impl Display]),
msg: format!(
"unexpected identifier: expected {} -- found '{found}'",
expected
.iter()
.map(|x| format!("'{x}'"))
.collect::<Vec<_>>()
.join(", "),
),
help: None,
}
@formatted
unexpected_statement {
args: (found: impl Display, expected: impl Display),
msg: format!("unexpected statement: expected '{expected}', found '{found}'"),
help: None,
}
@formatted
unexpected_str {
args: (found: impl Display, expected: impl Display),
msg: format!("unexpected string: expected '{expected}', found '{found}'"),
help: None,
}
@formatted
spread_in_array_init {
args: (),
msg: "illegal spread in array initializer",
help: None,
}
@backtraced
lexer_empty_input {
args: (),
msg: "Expected more characters to lex but found none.",
help: None,
}
@backtraced
lexer_expected_valid_escaped_char {
args: (input: impl Display),
msg: format!("Expected a valid escape character but found `{input}`."),
help: None,
}
@backtraced
lexer_string_not_closed {
args: (input: impl Display),
msg: format!("Expected a closed string but found `{input}`."),
help: None,
}
@backtraced
lexer_empty_block_comment {
args: (),
msg: "Empty block comment.",
help: None,
}
@backtraced
lexer_block_comment_does_not_close_before_eof {
args: (input: impl Display),
msg: format!("Block comment does not close with content: `{input}`."),
help: None,
}
@backtraced
could_not_lex {
args: (input: impl Display),
msg: format!("Could not lex the following content: `{input}`.\n"),
help: None,
}
@formatted
implicit_values_not_allowed {
args: (input: impl Display),
msg: format!("Could not parse the implicit value: {input}."),
help: None,
}
@backtraced
lexer_hex_number_provided {
args: (input: impl Display),
msg: format!("A hex number `{input}..` was provided but hex is not allowed."),
help: None,
}
@formatted
inputs_multiple_variable_modes_specified {
args: (),
msg: "A parameter cannot have multiple modes.",
help: Some("Consider using either `constant`, `public`, `private`, or none at all.".to_string()),
}
@backtraced
lexer_bidi_override {
args: (),
msg: "Unicode bidi override code point encountered.",
help: None,
}
@formatted
invalid_method_call {
args: (expr: impl Display, func: impl Display, num_args: impl Display),
msg: format!("The type of `{expr}` has no associated function `{func}` that takes {num_args} argument(s)."),
help: None,
}
@formatted
invalid_associated_access {
args: (name: impl Display),
msg: format!("Invalid associated access call to struct {name}."),
help: Some("Double colon `::` syntax is only supported for core functions in Leo for mainnet.".to_string()),
}
@formatted
leo_and_aleo_imports_only {
args: (),
msg: "Invalid import call to non-leo non-aleo file.",
help: Some("Only imports of Leo `.leo` and Aleo `.aleo` files are currently supported.".to_string()),
}
@formatted
space_in_annotation {
args: (),
msg: "Illegal spacing in the annotation declaration.",
help: Some("Remove whitespace between the `@` symbol and the identifier.".to_string()),
}
@formatted
circuit_is_deprecated {
args: (),
msg: "The keyword `circuit` is deprecated.",
help: Some("Use `struct` instead.".to_string()),
}
@formatted
only_one_program_scope_is_allowed {
args: (),
msg: "Only one program scope is allowed in a Leo file.",
help: None,
}
@formatted
missing_program_scope {
args: (),
msg: "Missing a program scope in a Leo file.",
help: Some("Add a program scope of the form: `program <name>.aleo { ... }` to the Leo file.".to_string()),
}
@formatted
invalid_network {
args: (),
msg: "Invalid network identifier. The only supported identifier is `.aleo`.",
help: None,
}
@formatted
tuple_must_have_at_least_two_elements {
args: (kind: impl Display),
msg: format!("A tuple {kind} must have at least two elements."),
help: None,
}
@formatted
async_finalize_is_deprecated {
args: (),
msg: format!("`async finalize` is deprecated."),
help: Some("Use `return <expr> then finalize(<args>)` instead.".to_string()),
}
@formatted
finalize_statements_are_deprecated {
args: (),
msg: format!("`finalize` statements are deprecated."),
help: Some("Use `return <expr> then finalize(<args>)` instead.".to_string()),
}
@formatted
console_statements_are_not_yet_supported {
args: (),
msg: format!("`console` statements are not yet supported."),
help: Some("Consider using `assert`, `assert_eq`, or `assert_neq` instead.".to_string()),
}
@formatted
tuple_index_must_be_whole_number {
args: (found: impl Display),
msg: format!("expected no underscores or leading zeros -- found '{found}'"),
help: None,
}
@formatted
array_must_have_at_least_one_element {
args: (kind: impl Display),
msg: format!("An array {kind} must have at least one element."),
help: None,
}
@formatted
invalid_external_type {
args: (),
msg: format!("Invalid external type."),
help: Some("External type should have the form `<program>.aleo/<record>`. For example `bank.aleo/loan`".to_string()),
}
@formatted
cannot_declare_external_struct {
args: (),
msg: format!("Cannot declare external struct."),
help: None,
}
@formatted
external_type_cannot_be_used_inside_function {
args: (program: impl Display, file_type: impl Display),
msg: format!("External types cannot be used inside function (only as input/output types) -- found exported type from '{program}.{file_type}'."),
help: None,
}
@formatted
cannot_import_inside_program_body {
args: (),
msg: format!("Cannot use import inside program body."),
help: None,
}
@formatted
only_aleo_external_calls {
args: (),
msg: format!("Only external calls to `.aleo` programs are supported."),
help: None,
}
@formatted
cannot_define_external_record {
args: (),
msg: format!("Cannot create an external record. Records can only be created in the program that they are defined in."),
help: None,
}
@formatted
comma_expected_after_member {
args: (),
msg: "Each member declaration in a struct or record must be followed by a comma (except the last).",
help: None,
}
@formatted
hexbin_literal_nonintegers {
args: (),
msg: format!("Hex, octal, and binary literals may only be used for integer types."),
help: None,
}
@backtraced
wrong_digit_for_radix {
args: (digit: char, radix: u32, token: String),
msg: format!("Digit {digit} invalid in radix {radix} (token {token})."),
help: None,
}
@formatted
identifier_too_long {
args: (ident: impl Display, length: usize, max_length: usize),
msg: format!("Identifier {ident} is too long ({length} bytes; maximum is {max_length})"),
help: None,
}
);