Skip to content

Commit

Permalink
impl Display for ReductionDiagnosticInfo;
Browse files Browse the repository at this point in the history
  • Loading branch information
greenhat committed Oct 3, 2023
1 parent 0fb4a87 commit 517153f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions ergotree-interpreter/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use ergotree_ir::mir::constant::TryExtractInto;
use ergotree_ir::pretty_printer::PosTrackingWriter;
use ergotree_ir::pretty_printer::Print;
use ergotree_ir::sigma_protocol::sigma_boolean::SigmaProp;
use std::fmt::Display;
use std::rc::Rc;

use ergotree_ir::mir::expr::Expr;
Expand Down Expand Up @@ -106,6 +107,15 @@ pub struct ReductionDiagnosticInfo {
pub pretty_printed_expr: Option<String>,
}

impl Display for ReductionDiagnosticInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
if let Some(expr_str) = &self.pretty_printed_expr {
writeln!(f, "Pretty printed expr:\n{}", expr_str)?;
}
write!(f, "Env:\n{}", self.env)
}
}

/// Result of expression reduction procedure (see `reduce_to_crypto`).
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct ReductionResult {
Expand Down
2 changes: 1 addition & 1 deletion ergotree-interpreter/src/sigma_protocol/prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub enum ProverError {
#[error("Script reduced to false")]
ReducedToFalse,
/// Script reduced to false with diagnostic info
#[error("Script reduced to false. Diagnostic info: {0:?}")]
#[error("Script reduced to false. Diagnostic info: {0}")]
ReducedToFalseWithDiag(ReductionDiagnosticInfo),
/// Failed on step2(prover does not have enough witnesses to perform the proof)
#[error("Failed on step2(prover does not have enough witnesses to perform the proof)")]
Expand Down

0 comments on commit 517153f

Please sign in to comment.