diff --git a/modcc/solvers.cpp b/modcc/solvers.cpp
index a636c9eef246b61c2b9d2cb900a28458048048d7..4e49ded06562b73ca100e431fdb6f004cd2ef83a 100644
--- a/modcc/solvers.cpp
+++ b/modcc/solvers.cpp
@@ -448,6 +448,7 @@ void SparseSolverVisitor::visit(ConserveExpression *e) {
 }
 
 void SparseSolverVisitor::finalize() {
+    if (has_error()) return;
 
     if (solve_variant_ == solverVariant::steadystate && !conserve_) {
         error({"Conserve statement(s) missing in steady-state solver", {}});
@@ -537,6 +538,8 @@ void LinearSolverVisitor::visit(LinearExpression *e) {
 }
 
 void LinearSolverVisitor::finalize() {
+    if (has_error()) return;
+
     system_.augment(rhs_);
 
     // Reduce the system
@@ -750,6 +753,7 @@ void SparseNonlinearSolverVisitor::visit(AssignmentExpression *e) {
 }
 
 void SparseNonlinearSolverVisitor::finalize() {
+    if (has_error()) return;
 
     // Create rhs of A_
     std::vector<std::string> rhs;