revise errors to allow stubs more leeway in parsing

This commit is contained in:
evan-schott 2023-11-30 10:40:22 -08:00
parent fb56a4f429
commit 0de4e81cc2
2 changed files with 30 additions and 24 deletions

View File

@ -252,7 +252,7 @@ create_messages!(
@formatted
invalid_network {
args: (),
msg: "Invalid network identifier. The only supported identifier is `aleo`.",
msg: "Invalid network identifier. The only supported identifier is `.aleo`.",
help: None,
}
@ -300,14 +300,6 @@ create_messages!(
help: None,
}
/// Enforce that cannot use an external type to do anything except input/output of function
@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,
}
/// Enforce that cannot use import in program scope
@formatted
cannot_import_inside_program_body {
@ -322,4 +314,18 @@ create_messages!(
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,
}
);

View File

@ -454,7 +454,7 @@ create_messages!(
help: None,
}
// TODO: Consider chainging this to a warning.
// TODO: Consider changing this to a warning.
@formatted
assign_unit_expression_to_variable {
@ -685,13 +685,6 @@ create_messages!(
help: None,
}
@formatted
stubs_can_only_have_records_and_transitions {
args: (found: impl Display),
msg: format!("Stubs can only have records, transitions, functions and imports -- found {found}"),
help: None,
}
@formatted
stub_functions_must_not_be_inlines {
args: (),
@ -706,13 +699,6 @@ create_messages!(
help: None,
}
@formatted
stub_functions_must_have_no_finalize {
args: (),
msg: format!("Function stubs must not have finalize blocks"),
help: None,
}
@formatted
array_empty {
args: (),
@ -740,4 +726,18 @@ create_messages!(
msg: format!("An array cannot have a record as an element type"),
help: None,
}
@formatted
stubs_cannot_have_non_record_structs {
args: (),
msg: format!("Stubs can only have records, transitions, functions, mappings and imports -- found non-record struct"),
help: None,
}
@formatted
stubs_cannot_have_const_declarations {
args: (),
msg: format!("Stubs can only have records, transitions, functions, mappings and imports -- found const declaration"),
help: None,
}
);