Skip to main content

leo_errors/errors/static_analyzer/
static_analyzer_warning.rs

1// Copyright (C) 2019-2026 Provable Inc.
2// This file is part of the Leo library.
3
4// The Leo library is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// The Leo library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
16
17use std::fmt::Display;
18
19create_messages!(
20    /// ParserWarning enum that represents all the warnings for static analysis
21    #[derive(Hash, Eq, PartialEq)]
22    StaticAnalyzerWarning,
23    code_mask: 4000i32,
24    code_prefix: "SAZ",
25
26    @formatted
27    some_paths_do_not_await_all_futures {
28        args: (num_total_paths: impl Display, num_unawaited_paths: impl Display),
29        msg: format!("Not all paths through the function await all futures. {num_unawaited_paths}/{num_total_paths} paths contain at least one future that is never awaited."),
30        help: Some("Ex: `f.await()` to await a future. Remove this warning by including the `--disable-conditional-branch-type-checking` flag.".to_string()),
31    }
32
33    @formatted
34    some_paths_contain_duplicate_future_awaits {
35        args: (num_total_paths: impl Display, num_duplicate_await_paths: impl Display),
36        msg: format!("Some paths through the function contain duplicate future awaits. {num_duplicate_await_paths}/{num_total_paths} paths contain at least one future that is awaited more than once."),
37        help: Some("Look at the times `.await()` is called, and try to reduce redundancies. Remove this warning by including the `--disable-conditional-branch-type-checking` flag.".to_string()),
38    }
39
40    @formatted
41    max_conditional_block_depth_exceeded {
42        args: (max: impl Display),
43        msg: format!("The type checker has exceeded the max depth of nested conditional blocks: {max}."),
44        help: Some("Re-run with a larger maximum depth using the `--conditional_block_max_depth` build option. Ex: `leo run main --conditional_block_max_depth 25`.".to_string()),
45    }
46
47    @formatted
48    future_not_awaited_in_order {
49        args: (future_name: impl Display),
50        msg: format!("The future `{}` is not awaited in the order in which they were passed in to the `async` function.", future_name),
51        help: Some("While it is not required for futures to be awaited in order, there is some specific behavior that arises, which may affect the semantics of your program. See `https://github.com/AleoNet/snarkVM/issues/2570` for more context.".to_string()),
52    }
53);