mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-11 13:56:58 +03:00
Fix error message
This commit is contained in:
parent
322c44308f
commit
4b64fbe03a
@ -17,7 +17,7 @@
|
||||
mod utilities;
|
||||
use utilities::{buffer_if_err, compile_and_process, get_cwd_option, parse_program, BufferEmitter, Network};
|
||||
|
||||
use crate::utilities::{hash_asts, hash_content, Aleo, get_build_options};
|
||||
use crate::utilities::{get_build_options, hash_asts, hash_content, Aleo};
|
||||
|
||||
use leo_errors::emitter::Handler;
|
||||
use leo_span::symbol::create_session_if_not_set_then;
|
||||
@ -28,12 +28,12 @@ use leo_test_framework::{
|
||||
|
||||
use snarkvm::{console, prelude::*};
|
||||
|
||||
use leo_compiler::{CompilerOptions, OutputOptions};
|
||||
use leo_test_framework::test::TestExpectationMode;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_yaml::Value;
|
||||
use std::{collections::BTreeMap, fs, path::Path, rc::Rc};
|
||||
use leo_compiler::{CompilerOptions, OutputOptions};
|
||||
|
||||
struct FinalizeNamespace;
|
||||
|
||||
@ -96,7 +96,8 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
|
||||
};
|
||||
|
||||
// Parse the program.
|
||||
let mut parsed = handler.extend_if_error(parse_program(handler, &test.content, cwd.clone(), Some(compiler_options)))?;
|
||||
let mut parsed =
|
||||
handler.extend_if_error(parse_program(handler, &test.content, cwd.clone(), Some(compiler_options)))?;
|
||||
|
||||
// Compile the program to bytecode.
|
||||
let bytecode = handler.extend_if_error(compile_and_process(&mut parsed))?;
|
||||
@ -105,8 +106,13 @@ fn run_test(test: Test, handler: &Handler, err_buf: &BufferEmitter) -> Result<Va
|
||||
let program_id = program.id();
|
||||
|
||||
// Extract the cases from the test config.
|
||||
let all_cases =
|
||||
test.config.extra.get("cases").expect("An `Finalize` config must have a `cases` field.").as_mapping().unwrap();
|
||||
let all_cases = test
|
||||
.config
|
||||
.extra
|
||||
.get("cases")
|
||||
.expect("An `Finalize` config must have a `cases` field.")
|
||||
.as_mapping()
|
||||
.unwrap();
|
||||
|
||||
// Extract the initial state from the test config.
|
||||
let initial_state = test
|
||||
|
@ -135,14 +135,14 @@ impl ParserContext<'_> {
|
||||
Expression::Identifier(Identifier { name: sym::decrement, .. }) => {
|
||||
self.emit_warning(ParserWarning::deprecated(
|
||||
"decrement",
|
||||
"Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings.",
|
||||
"Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings.",
|
||||
place.span(),
|
||||
));
|
||||
}
|
||||
Expression::Identifier(Identifier { name: sym::increment, .. }) => {
|
||||
self.emit_warning(ParserWarning::deprecated(
|
||||
"increment",
|
||||
"Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings.",
|
||||
"Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings.",
|
||||
place.span(),
|
||||
));
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
use crate::CodeGenerator;
|
||||
|
||||
use leo_ast::{
|
||||
AccessExpression,
|
||||
AssertStatement,
|
||||
AssertVariant,
|
||||
AssignStatement,
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372005]: Unknown function `decrement`\n --> compiler-test:11:9\n |\n 11 | decrement(amounts, addr, amount);\n | ^^^^^^^^^\nWarning [WPAR0370001]: The keyword `decrement` is deprecated.\n --> compiler-test:11:9\n |\n 11 | decrement(amounts, addr, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings."
|
||||
- "Error [ETYC0372005]: Unknown function `decrement`\n --> compiler-test:11:9\n |\n 11 | decrement(amounts, addr, amount);\n | ^^^^^^^^^\nWarning [WPAR0370001]: The keyword `decrement` is deprecated.\n --> compiler-test:11:9\n |\n 11 | decrement(amounts, addr, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings."
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372005]: Unknown function `increment`\n --> compiler-test:12:9\n |\n 12 | increment(account, receiver, amount);\n | ^^^^^^^^^\nError [ETYC0372071]: A finalize block cannot return a value.\n --> compiler-test:19:5\n |\n 19 | finalize public_adder(a: u8, b: u8) -> public u8 {\n 20 | return a + b;\n 21 | }\n | ^\nError [ETYC0372005]: Unknown function `increment`\n --> compiler-test:28:9\n |\n 28 | increment(values, 0u8, 1u8);\n | ^^^^^^^^^\nError [ETYC0372005]: Unknown function `increment`\n --> compiler-test:29:9\n |\n 29 | increment(account, self.caller, 1u64);\n | ^^^^^^^^^\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:12:9\n |\n 12 | increment(account, receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:28:9\n |\n 28 | increment(values, 0u8, 1u8);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:29:9\n |\n 29 | increment(account, self.caller, 1u64);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings."
|
||||
- "Error [ETYC0372005]: Unknown function `increment`\n --> compiler-test:12:9\n |\n 12 | increment(account, receiver, amount);\n | ^^^^^^^^^\nError [ETYC0372071]: A finalize block cannot return a value.\n --> compiler-test:19:5\n |\n 19 | finalize public_adder(a: u8, b: u8) -> public u8 {\n 20 | return a + b;\n 21 | }\n | ^\nError [ETYC0372005]: Unknown function `increment`\n --> compiler-test:28:9\n |\n 28 | increment(values, 0u8, 1u8);\n | ^^^^^^^^^\nError [ETYC0372005]: Unknown function `increment`\n --> compiler-test:29:9\n |\n 29 | increment(account, self.caller, 1u64);\n | ^^^^^^^^^\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:12:9\n |\n 12 | increment(account, receiver, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:28:9\n |\n 28 | increment(values, 0u8, 1u8);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings.\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:29:9\n |\n 29 | increment(account, self.caller, 1u64);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings."
|
||||
|
@ -2,4 +2,4 @@
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372005]: Unknown function `increment`\n --> compiler-test:11:9\n |\n 11 | increment(amounts, addr, amount);\n | ^^^^^^^^^\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:11:9\n |\n 11 | increment(amounts, addr, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings."
|
||||
- "Error [ETYC0372005]: Unknown function `increment`\n --> compiler-test:11:9\n |\n 11 | increment(amounts, addr, amount);\n | ^^^^^^^^^\nWarning [WPAR0370001]: The keyword `increment` is deprecated.\n --> compiler-test:11:9\n |\n 11 | increment(amounts, addr, amount);\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings."
|
||||
|
@ -2,11 +2,11 @@
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- initial_ast: bc6c3d26d53e50c2d9e55ca513f9f9ca5a51243e168abdabc519b6ab284ab4ca
|
||||
unrolled_ast: bc6c3d26d53e50c2d9e55ca513f9f9ca5a51243e168abdabc519b6ab284ab4ca
|
||||
ssa_ast: 9dec3f9ffc327edcbca8cd41fc43ed0ea547b2a21a83011561dcfa4eddc6f805
|
||||
flattened_ast: 14a0045dc7123f83d6ab8563c0ea931de77226a5debb18eb4f897e3a94c271ed
|
||||
inlined_ast: 14a0045dc7123f83d6ab8563c0ea931de77226a5debb18eb4f897e3a94c271ed
|
||||
dce_ast: 14a0045dc7123f83d6ab8563c0ea931de77226a5debb18eb4f897e3a94c271ed
|
||||
bytecode: 4352ef3dcfd2e624a555a365a9f307cee9a66cf0efb3c7681eb4c0b0014fa403
|
||||
warnings: ""
|
||||
- - initial_ast: bc6c3d26d53e50c2d9e55ca513f9f9ca5a51243e168abdabc519b6ab284ab4ca
|
||||
unrolled_ast: bc6c3d26d53e50c2d9e55ca513f9f9ca5a51243e168abdabc519b6ab284ab4ca
|
||||
ssa_ast: 9dec3f9ffc327edcbca8cd41fc43ed0ea547b2a21a83011561dcfa4eddc6f805
|
||||
flattened_ast: 14a0045dc7123f83d6ab8563c0ea931de77226a5debb18eb4f897e3a94c271ed
|
||||
inlined_ast: 14a0045dc7123f83d6ab8563c0ea931de77226a5debb18eb4f897e3a94c271ed
|
||||
dce_ast: 14a0045dc7123f83d6ab8563c0ea931de77226a5debb18eb4f897e3a94c271ed
|
||||
bytecode: 4352ef3dcfd2e624a555a365a9f307cee9a66cf0efb3c7681eb4c0b0014fa403
|
||||
warnings: ""
|
||||
|
@ -3,5 +3,5 @@ namespace: ParseStatement
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370005]: expected ; -- found '['\n --> test:1:10\n |\n 1 | decrement[foo, bar, baz];\n | ^"
|
||||
- "Error [EPAR0370005]: expected ; -- found '<eof>'\n --> test:1:15\n |\n 1 | decrement(floo)\n | ^Warning [WPAR0370001]: The keyword `decrement` is deprecated.\n --> test:1:1\n |\n 1 | decrement(floo)\n | ^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings."
|
||||
- "Error [EPAR0370005]: expected ; -- found '<eof>'\n --> test:1:15\n |\n 1 | decrement(floo)\n | ^Warning [WPAR0370001]: The keyword `decrement` is deprecated.\n --> test:1:1\n |\n 1 | decrement(floo)\n | ^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings."
|
||||
- "Error [EPAR0370005]: expected ; -- found 'foo'\n --> test:1:11\n |\n 1 | decrement foo[bar] by baz;\n | ^^^"
|
||||
|
@ -3,5 +3,5 @@ namespace: ParseStatement
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370005]: expected ; -- found '['\n --> test:1:10\n |\n 1 | increment[foo, bar, baz];\n | ^"
|
||||
- "Error [EPAR0370005]: expected ; -- found '<eof>'\n --> test:1:15\n |\n 1 | increment(floo)\n | ^Warning [WPAR0370001]: The keyword `increment` is deprecated.\n --> test:1:1\n |\n 1 | increment(floo)\n | ^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or, put}` for manipulating on-chain mappings."
|
||||
- "Error [EPAR0370005]: expected ; -- found '<eof>'\n --> test:1:15\n |\n 1 | increment(floo)\n | ^Warning [WPAR0370001]: The keyword `increment` is deprecated.\n --> test:1:1\n |\n 1 | increment(floo)\n | ^^^^^^^^^^^^^^^\n |\n = Use `Mapping::{get, get_or_init, set}` for manipulating on-chain mappings."
|
||||
- "Error [EPAR0370005]: expected ; -- found 'foo'\n --> test:1:11\n |\n 1 | increment foo[bar] by baz;\n | ^^^"
|
||||
|
Loading…
Reference in New Issue
Block a user