Revisions (underscore to execute test, type checker error msg, spurious type error fix, revised tuple indexing test)

This commit is contained in:
evan-schott 2023-08-25 09:49:53 -07:00
parent 90bb897130
commit 550f43b039
11 changed files with 75 additions and 75 deletions

View File

@ -164,7 +164,6 @@ impl<'a> ParserContext<'a> {
if (value.len() > 1 && value.starts_with('0')) || value.contains('_') {
return Err(ParserError::tuple_index_must_be_whole_number(
&self.token.token,
"whole number",
self.token.span,
)
.into());

View File

@ -307,10 +307,8 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
(Some(Value::U32(lower_bound, _)), Some(Value::U32(upper_bound, _))) => lower_bound >= upper_bound,
(Some(Value::U64(lower_bound, _)), Some(Value::U64(upper_bound, _))) => lower_bound >= upper_bound,
(Some(Value::U128(lower_bound, _)), Some(Value::U128(upper_bound, _))) => lower_bound >= upper_bound,
_ => {
self.emit_err(TypeCheckerError::loop_bound_type_mismatch(input.stop.span()));
false
}
// Note that type mismatch and non-literal errors will already be emitted by here.
_ => false
} {
self.emit_err(TypeCheckerError::loop_range_decreasing(input.stop.span()));
}

View File

@ -287,8 +287,8 @@ create_messages!(
/// Enforce that tuple index must not have leading 0, or underscore in between digits
@formatted
tuple_index_must_be_whole_number {
args: (found: impl Display, expected: impl Display),
msg: format!("expected {expected} -- found '{found}'"),
args: (found: impl Display),
msg: format!("expected no underscores or leading zeros -- found '{found}'"),
help: None,
}
);

View File

@ -646,7 +646,7 @@ create_messages!(
@formatted
loop_range_decreasing {
args: (),
msg: format!("The loop range must be decreasing."),
msg: format!("The loop range must be increasing."),
help: None,
}

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372008]: The value 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000 is not a valid `u64`\n --> compiler-test:7:28\n |\n 7 | for i:u64 in 0u64..1000000000000000000000000000000000000000000000000000000000000000000000000000000000000u64 {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372049]: Loop bound must be a literal.\n --> compiler-test:7:28\n |\n 7 | for i:u64 in 0u64..1000000000000000000000000000000000000000000000000000000000000000000000000000000000000u64 {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372079]: The loop bounds must be same type\n --> compiler-test:7:28\n |\n 7 | for i:u64 in 0u64..1000000000000000000000000000000000000000000000000000000000000000000000000000000000000u64 {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"
- "Error [ETYC0372008]: The value 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000 is not a valid `u64`\n --> compiler-test:7:28\n |\n 7 | for i:u64 in 0u64..1000000000000000000000000000000000000000000000000000000000000000000000000000000000000u64 {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nError [ETYC0372049]: Loop bound must be a literal.\n --> compiler-test:7:28\n |\n 7 | for i:u64 in 0u64..1000000000000000000000000000000000000000000000000000000000000000000000000000000000000u64 {\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372078]: The loop range must be decreasing.\n --> compiler-test:7:28\n |\n 7 | for i: i8 in 10i8..5i8 {\n | ^^^\n"
- "Error [ETYC0372078]: The loop range must be increasing.\n --> compiler-test:7:28\n |\n 7 | for i: i8 in 10i8..5i8 {\n | ^^^\n"

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372049]: Loop bound must be a literal.\n --> compiler-test:11:28\n |\n 11 | for i:u64 in 0u64..amount {\n | ^^^^^^\nError [ETYC0372079]: The loop bounds must be same type\n --> compiler-test:11:28\n |\n 11 | for i:u64 in 0u64..amount {\n | ^^^^^^\n"
- "Error [ETYC0372049]: Loop bound must be a literal.\n --> compiler-test:11:28\n |\n 11 | for i:u64 in 0u64..amount {\n | ^^^^^^\n"

View File

@ -2,13 +2,13 @@
namespace: Execute
expectation: Pass
outputs:
- - initial_ast: ff08a4a92839ebe43e5c035ff1ab8991da994f84b167630c9b26cdc8e30028e6
unrolled_ast: ff08a4a92839ebe43e5c035ff1ab8991da994f84b167630c9b26cdc8e30028e6
ssa_ast: 8fea46feeceac4607d6e09181bce795520d9403f0be606b049225459f10dfe47
flattened_ast: 561824a5b5b1291ca6d59dace67780a62c1089536e895830f901c133fa74da85
inlined_ast: 561824a5b5b1291ca6d59dace67780a62c1089536e895830f901c133fa74da85
dce_ast: 561824a5b5b1291ca6d59dace67780a62c1089536e895830f901c133fa74da85
bytecode: f6055195b401bef6fe1e686a256bb743941b1945b7fd4b8f1800aa83dc3b7495
- - initial_ast: 437dad4042f19f778819ccccf9964ff9b6b701c2805417ba378d8d5d643d59bc
unrolled_ast: 437dad4042f19f778819ccccf9964ff9b6b701c2805417ba378d8d5d643d59bc
ssa_ast: 8f85576cdcb97f4b8c348fbad7ab7d85696cbdc1a26a19226903446785db9d20
flattened_ast: 83c91f6cefa549e6fc788d063aa22446b095e1b37e8a20d2109c2ba10068230a
inlined_ast: 83c91f6cefa549e6fc788d063aa22446b095e1b37e8a20d2109c2ba10068230a
dce_ast: 83c91f6cefa549e6fc788d063aa22446b095e1b37e8a20d2109c2ba10068230a
bytecode: 18d3fa0f122b8bc035d12ca6fbca2d0d6c923e9ebde740ebf8101b34ee38102a
warnings: ""
results:
dubble:

View File

@ -2,56 +2,57 @@
namespace: ParseStatement
expectation: Fail
outputs:
- "Error [EPAR0370033]: expected whole number -- found ';'\n --> test:1:5\n |\n 1 | x.0_;\n | ^"
- "Error [EPAR0370033]: expected whole number -- found ';'\n --> test:1:6\n |\n 1 | x.0_0;\n | ^"
- "Error [EPAR0370033]: expected whole number -- found ';'\n --> test:1:5\n |\n 1 | x.01;\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '.'\n --> test:1:5\n |\n 1 | x.0_.\n | ^"
- "Error [EPAR0370033]: expected whole number -- found 'import'\n --> test:1:5\n |\n 1 | x.0_import\n | ^^^^^^"
- "Error [EPAR0370033]: expected whole number -- found ','\n --> test:1:5\n |\n 1 | x.0_,\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '*'\n --> test:1:5\n |\n 1 | x.0_*\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '+'\n --> test:1:5\n |\n 1 | x.0_+\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '-'\n --> test:1:5\n |\n 1 | x.0_-\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '/'\n --> test:1:5\n |\n 1 | x.0_/\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '['\n --> test:1:5\n |\n 1 | x.0_[\n | ^"
- "Error [EPAR0370033]: expected whole number -- found ']'\n --> test:1:5\n |\n 1 | x.0_]\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '{'\n --> test:1:5\n |\n 1 | x.0_{\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '}'\n --> test:1:5\n |\n 1 | x.0_}\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '('\n --> test:1:5\n |\n 1 | x.0_(\n | ^"
- "Error [EPAR0370033]: expected whole number -- found ')'\n --> test:1:5\n |\n 1 | x.0_)\n | ^"
- "Error [EPAR0370033]: expected whole number -- found ':'\n --> test:1:5\n |\n 1 | x.0_:\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '::'\n --> test:1:5\n |\n 1 | x.0_::\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found '?'\n --> test:1:5\n |\n 1 | x.0_?\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '<eof>'\n --> test:1:3\n |\n 1 | x.0__\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found '='\n --> test:1:5\n |\n 1 | x.0_=\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '=='\n --> test:1:5\n |\n 1 | x.0_==\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found '!'\n --> test:1:5\n |\n 1 | x.0_!\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '!='\n --> test:1:5\n |\n 1 | x.0_!=\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '>='\n --> test:1:5\n |\n 1 | x.0_>=\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found '<'\n --> test:1:5\n |\n 1 | x.0_<\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '<='\n --> test:1:5\n |\n 1 | x.0_<=\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
- "Error [EPAR0370033]: expected whole number -- found '..'\n --> test:1:5\n |\n 1 | x.0_..\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found 'as'\n --> test:1:5\n |\n 1 | x.0_as\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found 'console'\n --> test:1:5\n |\n 1 | x.0_console\n | ^^^^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'const'\n --> test:1:5\n |\n 1 | x.0_const\n | ^^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'let'\n --> test:1:5\n |\n 1 | x.0_let\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'for'\n --> test:1:5\n |\n 1 | x.0_for\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'if'\n --> test:1:5\n |\n 1 | x.0_if\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found 'else'\n --> test:1:5\n |\n 1 | x.0_else\n | ^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'i8'\n --> test:1:5\n |\n 1 | x.0_i8\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found 'i16'\n --> test:1:5\n |\n 1 | x.0_i16\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'i32'\n --> test:1:5\n |\n 1 | x.0_i32\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'i64'\n --> test:1:5\n |\n 1 | x.0_i64\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'i128'\n --> test:1:5\n |\n 1 | x.0_i128\n | ^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'u8'\n --> test:1:5\n |\n 1 | x.0_u8\n | ^^"
- "Error [EPAR0370033]: expected whole number -- found 'u16'\n --> test:1:5\n |\n 1 | x.0_u16\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'u32'\n --> test:1:5\n |\n 1 | x.0_u32\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'u64'\n --> test:1:5\n |\n 1 | x.0_u64\n | ^^^"
- "Error [EPAR0370033]: expected whole number -- found 'u128'\n --> test:1:5\n |\n 1 | x.0_u128\n | ^^^^"
- "Error [EPAR0370033]: expected whole number -- found '&'\n --> test:1:5\n |\n 1 | x.0_&\n | ^"
- "Error [EPAR0370033]: expected whole number -- found 'return'\n --> test:1:5\n |\n 1 | x.0_return\n | ^^^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'self'\n --> test:1:5\n |\n 1 | x.0_self\n | ^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'Self'\n --> test:1:5\n |\n 1 | x.0_Self\n | ^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'true'\n --> test:1:5\n |\n 1 | x.0_true\n | ^^^^"
- "Error [EPAR0370033]: expected whole number -- found 'false'\n --> test:1:5\n |\n 1 | x.0_false\n | ^^^^^"
- "Error [EPAR0370009]: unexpected string: expected 'identifier', found '-'\n --> test:1:3\n |\n 1 | x.-12\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ';'\n --> test:1:5\n |\n 1 | x.0_;\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ';'\n --> test:1:6\n |\n 1 | x.0_0;\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ';'\n --> test:1:5\n |\n 1 | x.01;\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '.'\n --> test:1:5\n |\n 1 | x.0_.\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'import'\n --> test:1:5\n |\n 1 | x.0_import\n | ^^^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ','\n --> test:1:5\n |\n 1 | x.0_,\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '*'\n --> test:1:5\n |\n 1 | x.0_*\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '+'\n --> test:1:5\n |\n 1 | x.0_+\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '-'\n --> test:1:5\n |\n 1 | x.0_-\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '/'\n --> test:1:5\n |\n 1 | x.0_/\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '['\n --> test:1:5\n |\n 1 | x.0_[\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ']'\n --> test:1:5\n |\n 1 | x.0_]\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '{'\n --> test:1:5\n |\n 1 | x.0_{\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '}'\n --> test:1:5\n |\n 1 | x.0_}\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '('\n --> test:1:5\n |\n 1 | x.0_(\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ')'\n --> test:1:5\n |\n 1 | x.0_)\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found ':'\n --> test:1:5\n |\n 1 | x.0_:\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '::'\n --> test:1:5\n |\n 1 | x.0_::\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '?'\n --> test:1:5\n |\n 1 | x.0_?\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '<eof>'\n --> test:1:3\n |\n 1 | x.0__\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '='\n --> test:1:5\n |\n 1 | x.0_=\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '=='\n --> test:1:5\n |\n 1 | x.0_==\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '!'\n --> test:1:5\n |\n 1 | x.0_!\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '!='\n --> test:1:5\n |\n 1 | x.0_!=\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '>='\n --> test:1:5\n |\n 1 | x.0_>=\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '<'\n --> test:1:5\n |\n 1 | x.0_<\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '<='\n --> test:1:5\n |\n 1 | x.0_<=\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '..'\n --> test:1:5\n |\n 1 | x.0_..\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'as'\n --> test:1:5\n |\n 1 | x.0_as\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'console'\n --> test:1:5\n |\n 1 | x.0_console\n | ^^^^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'const'\n --> test:1:5\n |\n 1 | x.0_const\n | ^^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'let'\n --> test:1:5\n |\n 1 | x.0_let\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'for'\n --> test:1:5\n |\n 1 | x.0_for\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'if'\n --> test:1:5\n |\n 1 | x.0_if\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'else'\n --> test:1:5\n |\n 1 | x.0_else\n | ^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i8'\n --> test:1:5\n |\n 1 | x.0_i8\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i16'\n --> test:1:5\n |\n 1 | x.0_i16\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i32'\n --> test:1:5\n |\n 1 | x.0_i32\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i64'\n --> test:1:5\n |\n 1 | x.0_i64\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i128'\n --> test:1:5\n |\n 1 | x.0_i128\n | ^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u8'\n --> test:1:5\n |\n 1 | x.0_u8\n | ^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u16'\n --> test:1:5\n |\n 1 | x.0_u16\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u32'\n --> test:1:5\n |\n 1 | x.0_u32\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u64'\n --> test:1:5\n |\n 1 | x.0_u64\n | ^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u128'\n --> test:1:5\n |\n 1 | x.0_u128\n | ^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found '&'\n --> test:1:5\n |\n 1 | x.0_&\n | ^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'return'\n --> test:1:5\n |\n 1 | x.0_return\n | ^^^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'self'\n --> test:1:5\n |\n 1 | x.0_self\n | ^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'Self'\n --> test:1:5\n |\n 1 | x.0_Self\n | ^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'true'\n --> test:1:5\n |\n 1 | x.0_true\n | ^^^^"
- "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'false'\n --> test:1:5\n |\n 1 | x.0_false\n | ^^^^^"

View File

@ -19,10 +19,10 @@ program test.aleo {
}
finalize dubble(addr: address) {
let current_value: u64 = Mapping::get_or_use(counter, addr, 0u64);
Mapping::set(counter, addr, current_value + 1u64);
let current_value: u64 = Mapping::get_or_use(counter, addr, 0_0u64);
Mapping::set(counter, addr, current_value + 1__u64);
current_value = Mapping::get(counter, addr);
Mapping::set(counter, addr, current_value + 1u64);
Mapping::set(counter, addr, current_value + 0___1u64);
}
transition unsafe_increment() {
@ -31,6 +31,6 @@ program test.aleo {
finalize unsafe_increment(addr: address) {
let current_value: u64 = Mapping::get(counter, addr);
Mapping::set(counter, addr, current_value + 1u64);
Mapping::set(counter, addr, current_value + 0__1u64);
}
}

View File

@ -3,6 +3,8 @@ namespace: ParseStatement
expectation: Fail
*/
x.-12
x.0_;
x.0_0;