mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-01 10:17:30 +03:00
Merge pull request #862 from AleoHQ/force-u32-in-loops
[Compiler] Forcing u32 in iterators
This commit is contained in:
commit
023ae6c73d
@ -54,7 +54,7 @@ impl<'a> FromAst<'a, leo_ast::IterationStatement> for &'a Statement<'a> {
|
||||
statement: &leo_ast::IterationStatement,
|
||||
_expected_type: Option<PartialType<'a>>,
|
||||
) -> Result<Self, AsgConvertError> {
|
||||
let expected_index_type = Some(PartialType::Integer(None, Some(IntegerType::U32)));
|
||||
let expected_index_type = Some(PartialType::Integer(Some(IntegerType::U32), None));
|
||||
let start = <&Expression<'a>>::from_ast(scope, &statement.start, expected_index_type.clone())?;
|
||||
let stop = <&Expression<'a>>::from_ast(scope, &statement.stop, expected_index_type)?;
|
||||
|
||||
|
9
compiler/tests/statements/iteration_type_fail.leo
Normal file
9
compiler/tests/statements/iteration_type_fail.leo
Normal file
@ -0,0 +1,9 @@
|
||||
// code sample is from fuzzing bug
|
||||
// https://github.com/AleoHQ/leo/issues/758
|
||||
function main (
|
||||
x: u8,
|
||||
) {
|
||||
for y in 0u8..10u8 {
|
||||
let z = y > x;
|
||||
}
|
||||
}
|
@ -82,6 +82,14 @@ fn test_iteration_input() {
|
||||
expect_asg_error(error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iteration_wrong_type() {
|
||||
let program_string = include_str!("iteration_type_fail.leo");
|
||||
let error = parse_program(program_string).err().unwrap();
|
||||
|
||||
expect_asg_error(error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_iteration_variable() {
|
||||
let program_string = include_str!("iteration_variable.leo");
|
||||
|
Loading…
Reference in New Issue
Block a user