Skip to content

Commit

Permalink
Throwing instead of an assert if we cannot find the block to solve (#922
Browse files Browse the repository at this point in the history
)

Otherwise it only segmentation fault in Release
  • Loading branch information
alkino committed Sep 5, 2022
1 parent 60249f1 commit 4984c31
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/visitors/solve_block_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "visitors/solve_block_visitor.hpp"

#include <cassert>
#include <fmt/format.h>

#include "ast/all.hpp"
#include "codegen/codegen_naming.hpp"
Expand Down Expand Up @@ -42,7 +43,10 @@ ast::SolutionExpression* SolveBlockVisitor::create_solution_expression(
/// find out the block that is going to solved
const auto& block_name = solve_block.get_block_name()->get_node_name();
const auto& solve_node_symbol = symtab->lookup(block_name);
assert(solve_node_symbol != nullptr);
if (solve_node_symbol == nullptr) {
throw std::runtime_error(
fmt::format("SolveBlockVisitor :: cannot find the block '{}' to solve it", block_name));
}
auto node_to_solve = solve_node_symbol->get_node();

/// in case of derivimplicit method if neuron solver is used (i.e. not sympy) then
Expand Down

0 comments on commit 4984c31

Please sign in to comment.