mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-25 11:12:48 +03:00
Add consty checks. Closes #749.
This commit is contained in:
parent
1fbd337fec
commit
0aa71ed3f9
@ -57,6 +57,19 @@ impl<'a> FromAst<'a, leo_ast::IterationStatement> for &'a Statement<'a> {
|
||||
let expected_index_type = Some(PartialType::Integer(None, Some(IntegerType::U32)));
|
||||
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)?;
|
||||
|
||||
// Return an error if start or stop is not constant.
|
||||
if !start.is_consty() {
|
||||
return Err(AsgConvertError::unexpected_nonconst(
|
||||
&start.span().cloned().unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
if !stop.is_consty() {
|
||||
return Err(AsgConvertError::unexpected_nonconst(
|
||||
&stop.span().cloned().unwrap_or_default(),
|
||||
));
|
||||
}
|
||||
|
||||
let variable = scope.alloc_variable(RefCell::new(InnerVariable {
|
||||
id: scope.context.get_id(),
|
||||
name: statement.variable.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user