Merge pull request #862 from AleoHQ/force-u32-in-loops

[Compiler] Forcing u32 in iterators
This commit is contained in:
Collin Chin 2021-04-14 14:15:07 -07:00 committed by GitHub
commit 023ae6c73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View File

@ -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)?;

View 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;
}
}

View File

@ -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");