1
0
Fork 0
mirror of synced 2025-09-23 04:08:33 +00:00

fix formatting

This commit is contained in:
dark64 2022-11-30 14:57:41 +01:00
parent eca20870e1
commit 226b65288a
5 changed files with 14 additions and 17 deletions

View file

@ -570,15 +570,16 @@ impl<'ast, 'a, T: Field> ResultFolder<'ast, T> for Propagator<'ast, 'a, T> {
}
}
}
TypedStatement::Assertion(e, ty) => {
TypedStatement::Assertion(e, err) => {
let e_str = e.to_string();
let expr = self.fold_boolean_expression(e)?;
match expr {
BooleanExpression::Value(false) => {
Err(Error::AssertionFailed(format!("{}: ({})", ty, e_str)))
}
BooleanExpression::Value(false) => Err(Error::AssertionFailed(format!(
"Assertion failed `{}` ({})",
e_str, err
))),
BooleanExpression::Value(true) => Ok(vec![]),
_ => Ok(vec![TypedStatement::Assertion(expr, ty)]),
_ => Ok(vec![TypedStatement::Assertion(expr, err)]),
}
}
s @ TypedStatement::PushCallLog(..) => Ok(vec![s]),

View file

@ -35,7 +35,7 @@ impl fmt::Display for Error {
Error::DivisionByZero => {
write!(f, "Division by zero detected in zir during static analysis",)
}
Error::AssertionFailed(err) => write!(f, "Assertion failed: `{}`", err),
Error::AssertionFailed(err) => write!(f, "Assertion failed ({})", err),
}
}
}

View file

@ -577,9 +577,7 @@ pub enum RuntimeError {
impl fmt::Display for RuntimeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
RuntimeError::SourceAssertion(metadata) => {
write!(f, "Assertion failed at {}", metadata)
}
RuntimeError::SourceAssertion(metadata) => write!(f, "{}", metadata),
RuntimeError::SelectRangeCheck => write!(f, "Range check on array access"),
RuntimeError::DivisionByZero => write!(f, "Division by zero"),
}
@ -674,10 +672,10 @@ impl<'ast, T: fmt::Display> fmt::Display for TypedAssemblyStatement<'ast, T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
TypedAssemblyStatement::Assignment(ref lhs, ref rhs) => {
write!(f, "{} <-- {}", lhs, rhs)
write!(f, "{} <-- {};", lhs, rhs)
}
TypedAssemblyStatement::Constraint(ref lhs, ref rhs, _) => {
write!(f, "{} === {}", lhs, rhs)
write!(f, "{} === {};", lhs, rhs)
}
}
}

View file

@ -103,9 +103,7 @@ pub enum RuntimeError {
impl fmt::Display for RuntimeError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
RuntimeError::SourceAssertion(metadata) => {
write!(f, "Assertion failed at {}", metadata)
}
RuntimeError::SourceAssertion(metadata) => write!(f, "{}", metadata),
RuntimeError::SelectRangeCheck => write!(f, "Range check on array access"),
RuntimeError::DivisionByZero => write!(f, "Division by zero"),
RuntimeError::IncompleteDynamicRange => write!(f, "Dynamic comparison is incomplete"),
@ -138,7 +136,7 @@ impl<'ast, T: fmt::Display> fmt::Display for ZirAssemblyStatement<'ast, T> {
ZirAssemblyStatement::Assignment(ref lhs, ref rhs) => {
write!(
f,
"{} <-- {}",
"{} <-- {};",
lhs.iter()
.map(|a| a.id.to_string())
.collect::<Vec<String>>()
@ -147,7 +145,7 @@ impl<'ast, T: fmt::Display> fmt::Display for ZirAssemblyStatement<'ast, T> {
)
}
ZirAssemblyStatement::Constraint(ref lhs, ref rhs, _) => {
write!(f, "{} === {}", lhs, rhs)
write!(f, "{} === {};", lhs, rhs)
}
}
}

View file

@ -433,7 +433,7 @@ mod ast {
pub span: Span<'ast>,
}
#[derive(Debug, FromPest, PartialEq, Clone)]
#[derive(Debug, FromPest, PartialEq, Eq, Clone)]
#[pest_ast(rule(Rule::op_asm))]
pub enum AssignmentOperator {
Assign(AssignOperator),