diff --git a/compiler/src/expression/binary/binary.rs b/compiler/src/expression/binary/binary.rs index 2ccf90d2d2..02b54f53d3 100644 --- a/compiler/src/expression/binary/binary.rs +++ b/compiler/src/expression/binary/binary.rs @@ -24,6 +24,8 @@ use snarkos_models::{ gadgets::r1cs::ConstraintSystem, }; +type ConstrainedValuePair = (ConstrainedValue, ConstrainedValue); + impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_binary_expression>( @@ -35,7 +37,7 @@ impl> ConstrainedProgram { left: Expression, right: Expression, span: Span, - ) -> Result<(ConstrainedValue, ConstrainedValue), ExpressionError> { + ) -> Result, ExpressionError> { let mut resolved_left = self.enforce_operand( cs, file_scope.clone(), diff --git a/compiler/src/statement/branch/branch.rs b/compiler/src/statement/branch/branch.rs index abbadee733..bd7cd35858 100644 --- a/compiler/src/statement/branch/branch.rs +++ b/compiler/src/statement/branch/branch.rs @@ -16,7 +16,7 @@ //! Enforces a branch of a conditional or iteration statement in a compiled Leo program. -use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use crate::{program::ConstrainedProgram, GroupType, IndicatorAndConstrainedValue, StatementResult}; use leo_typed::{Statement, Type}; use snarkos_models::{ @@ -33,7 +33,7 @@ impl> ConstrainedProgram { indicator: Option, statements: Vec, return_type: Option, - ) -> Result, ConstrainedValue)>, StatementError> { + ) -> StatementResult>> { let mut results = vec![]; // Evaluate statements. Only allow a single return argument to be returned. for statement in statements.iter() { diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index cdb85fd4c6..c70a6990aa 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -16,7 +16,10 @@ //! Methods to enforce constraints on statements in a compiled Leo program. -use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; +use crate::{ + errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType, + IndicatorAndConstrainedValue, StatementResult +}; use leo_typed::{ConditionalNestedOrEndStatement, ConditionalStatement, Span, Type}; use snarkos_models::{ @@ -46,7 +49,7 @@ impl> ConstrainedProgram { statement: ConditionalStatement, return_type: Option, span: Span, - ) -> Result, ConstrainedValue)>, StatementError> { + ) -> StatementResult>> { let statement_string = statement.to_string(); // Inherit the indicator from a previous conditional statement or assume that we are the outer parent diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index 0a3f01ee75..7503f7571c 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -17,12 +17,13 @@ //! Enforces an iteration statement in a compiled Leo program. use crate::{ - errors::StatementError, new_scope, program::ConstrainedProgram, value::ConstrainedValue, GroupType, + IndicatorAndConstrainedValue, Integer, + StatementResult, }; use leo_typed::{Expression, Identifier, Span, Statement, Type}; @@ -48,7 +49,7 @@ impl> ConstrainedProgram { statements: Vec, return_type: Option, span: Span, - ) -> Result, ConstrainedValue)>, StatementError> { + ) -> StatementResult>> { let mut results = vec![]; let from = self.enforce_index(cs, file_scope.clone(), function_scope.clone(), start, span.clone())?; diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 35e293a310..f3e66035aa 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -24,6 +24,9 @@ use snarkos_models::{ gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; +pub type StatementResult = Result; +pub type IndicatorAndConstrainedValue = (Option, ConstrainedValue); + impl> ConstrainedProgram { /// Enforce a program statement. /// Returns a Vector of (indicator, value) tuples. @@ -40,7 +43,7 @@ impl> ConstrainedProgram { statement: Statement, return_type: Option, declared_circuit_reference: String, - ) -> Result, ConstrainedValue)>, StatementError> { + ) -> StatementResult>> { let mut results = vec![]; match statement {