mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-25 18:42:26 +03:00
fix stack overflow error caused by SynthesisError
This commit is contained in:
parent
a704eddb51
commit
55d6dc5cc6
@ -51,13 +51,19 @@ impl ExpressionError {
|
||||
|
||||
pub fn cannot_enforce(operation: String, error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!(
|
||||
"the gadget operation `{}` failed due to synthesis error `{}`",
|
||||
"the gadget operation `{}` failed due to synthesis error `{:?}`",
|
||||
operation, error,
|
||||
);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
||||
pub fn cannot_evaluate(operation: String, span: Span) -> Self {
|
||||
let message = format!("Mismatched types found for operation `{}`", operation);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
||||
pub fn conditional_boolean(actual: String, span: Span) -> Self {
|
||||
let message = format!("if, else conditional must resolve to a boolean, found `{}`", actual);
|
||||
|
||||
|
@ -28,7 +28,7 @@ impl AddressError {
|
||||
|
||||
pub fn cannot_enforce(operation: String, error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!(
|
||||
"the address operation `{}` failed due to the synthesis error `{}`",
|
||||
"the address operation `{:?}` failed due to the synthesis error `{}`",
|
||||
operation, error,
|
||||
);
|
||||
|
||||
|
@ -22,7 +22,7 @@ impl BooleanError {
|
||||
|
||||
pub fn cannot_enforce(operation: String, error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!(
|
||||
"the boolean operation `{}` failed due to the synthesis error `{}`",
|
||||
"the boolean operation `{}` failed due to the synthesis error `{:?}`",
|
||||
operation, error,
|
||||
);
|
||||
|
||||
|
@ -21,14 +21,14 @@ impl FieldError {
|
||||
}
|
||||
|
||||
pub fn negate_operation(error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!("field negation failed due to synthesis error `{}`", error,);
|
||||
let message = format!("field negation failed due to synthesis error `{:?}`", error,);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
||||
pub fn binary_operation(operation: String, error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!(
|
||||
"the field binary operation `{}` failed due to synthesis error `{}`",
|
||||
"the field binary operation `{}` failed due to synthesis error `{:?}`",
|
||||
operation, error,
|
||||
);
|
||||
|
||||
@ -54,7 +54,7 @@ impl FieldError {
|
||||
}
|
||||
|
||||
pub fn synthesis_error(error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!("compilation failed due to field synthesis error `{}`", error);
|
||||
let message = format!("compilation failed due to field synthesis error `{:?}`", error);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ impl GroupError {
|
||||
}
|
||||
|
||||
pub fn negate_operation(error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!("group negation failed due to the synthesis error `{}`", error,);
|
||||
let message = format!("group negation failed due to the synthesis error `{:?}`", error,);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
||||
pub fn binary_operation(operation: String, error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!(
|
||||
"the group binary operation `{}` failed due to the synthesis error `{}`",
|
||||
"the group binary operation `{}` failed due to the synthesis error `{:?}`",
|
||||
operation, error,
|
||||
);
|
||||
|
||||
@ -48,7 +48,7 @@ impl GroupError {
|
||||
}
|
||||
|
||||
pub fn synthesis_error(error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!("compilation failed due to group synthesis error `{}`", error);
|
||||
let message = format!("compilation failed due to group synthesis error `{:?}`", error);
|
||||
|
||||
Self::new_from_span(message, span)
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ impl IntegerError {
|
||||
|
||||
pub fn cannot_enforce(operation: String, error: SynthesisError, span: Span) -> Self {
|
||||
let message = format!(
|
||||
"the integer operation `{}` failed due to the synthesis error `{}`",
|
||||
"the integer operation `{}` failed due to the synthesis error `{:?}`",
|
||||
operation, error,
|
||||
);
|
||||
|
||||
|
@ -47,7 +47,7 @@ pub fn evaluate_eq<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<
|
||||
}
|
||||
};
|
||||
|
||||
let boolean = constraint_result.map_err(|e| ExpressionError::cannot_enforce(format!("evaluate equal"), e, span))?;
|
||||
let boolean = constraint_result.map_err(|_| ExpressionError::cannot_evaluate(format!("=="), span))?;
|
||||
|
||||
Ok(ConstrainedValue::Boolean(boolean))
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ pub fn evaluate_ge<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<
|
||||
}
|
||||
};
|
||||
|
||||
let boolean = constraint_result
|
||||
.map_err(|e| ExpressionError::cannot_enforce(format!("evaluate greater than or equal"), e, span))?;
|
||||
let boolean = constraint_result.map_err(|_| ExpressionError::cannot_evaluate(format!(">="), span))?;
|
||||
|
||||
Ok(ConstrainedValue::Boolean(boolean))
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ pub fn evaluate_gt<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<
|
||||
}
|
||||
};
|
||||
|
||||
let boolean =
|
||||
constraint_result.map_err(|e| ExpressionError::cannot_enforce(format!("evaluate greater than"), e, span))?;
|
||||
let boolean = constraint_result.map_err(|_| ExpressionError::cannot_evaluate(format!(">"), span))?;
|
||||
|
||||
Ok(ConstrainedValue::Boolean(boolean))
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ pub fn evaluate_le<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<
|
||||
}
|
||||
};
|
||||
|
||||
let boolean = constraint_result
|
||||
.map_err(|e| ExpressionError::cannot_enforce(format!("evaluate less than or equal"), e, span))?;
|
||||
let boolean = constraint_result.map_err(|_| ExpressionError::cannot_evaluate(format!("<="), span))?;
|
||||
|
||||
Ok(ConstrainedValue::Boolean(boolean))
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ pub fn evaluate_lt<F: Field + PrimeField, G: GroupType<F>, CS: ConstraintSystem<
|
||||
}
|
||||
};
|
||||
|
||||
let boolean =
|
||||
constraint_result.map_err(|e| ExpressionError::cannot_enforce(format!("evaluate less than"), e, span))?;
|
||||
let boolean = constraint_result.map_err(|_| ExpressionError::cannot_evaluate(format!("<"), span))?;
|
||||
|
||||
Ok(ConstrainedValue::Boolean(boolean))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user