diff --git a/ergotree-interpreter/src/eval.rs b/ergotree-interpreter/src/eval.rs index 77e09833b..8535163a7 100644 --- a/ergotree-interpreter/src/eval.rs +++ b/ergotree-interpreter/src/eval.rs @@ -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; @@ -106,6 +107,15 @@ pub struct ReductionDiagnosticInfo { pub pretty_printed_expr: Option, } +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 { diff --git a/ergotree-interpreter/src/sigma_protocol/prover.rs b/ergotree-interpreter/src/sigma_protocol/prover.rs index c4a0267c1..4dee08edc 100644 --- a/ergotree-interpreter/src/sigma_protocol/prover.rs +++ b/ergotree-interpreter/src/sigma_protocol/prover.rs @@ -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)")]