diff --git a/eval.cpp b/eval.cpp index 13e87f7..d99a24b 100644 --- a/eval.cpp +++ b/eval.cpp @@ -125,5 +125,9 @@ double eval(Expr *e) { EvalVisitor visitor; e->visit(visitor); - return visitor.stack[visitor.depth-1]; + + if (visitor.fail) + return 0; + else + return visitor.stack[visitor.depth-1]; }