diff --git a/src/error.rs b/src/error.rs index aaddc77..7df44c3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -35,10 +35,9 @@ impl Traceback { Traceback(vec![]) } - pub fn with_trace(&self, item: TraceItem) -> Traceback { - let mut next = Traceback(self.0.clone()); - next.0.push(item); - next + pub fn with_trace(mut self, item: TraceItem) -> Traceback { + self.0.push(item); + self } pub fn depth(&self) -> usize { diff --git a/src/stl/control.rs b/src/stl/control.rs index 2544603..0d45cce 100644 --- a/src/stl/control.rs +++ b/src/stl/control.rs @@ -330,7 +330,7 @@ example: (circuit (eq? (do-operation) myresult) in this example, do-another-operation will not be called"; fn circuit_callback(ast: &Seg, syms: &mut SymTable) -> Result { let mut cursor = 0; - let mut err_trace = Traceback::new(); + let mut err_trace: Traceback = Traceback::new(); let result = ast.circuit(&mut |form: &Ctr| -> bool { cursor += 1; let operand: &Seg; @@ -358,7 +358,7 @@ fn circuit_callback(ast: &Seg, syms: &mut SymTable) -> Result { } else if let Ctr::Integer(i) = *s.car { return i==0; } else { - err_trace = err_trace.with_trace( + err_trace = err_trace.clone().with_trace( ("circuit", "impossible condition") .into()); } @@ -366,7 +366,7 @@ fn circuit_callback(ast: &Seg, syms: &mut SymTable) -> Result { Ctr::Integer(i) => return i == 0, - _ => err_trace = err_trace.with_trace( + _ => err_trace = err_trace.clone().with_trace( ("circuit", format!("form {cursor} did not evaluate to a boolean")) .into()), },