Skip to content

Commit

Permalink
Fixed bug in user-propagator "created" (#5843)
Browse files Browse the repository at this point in the history
  • Loading branch information
CEisenhofer authored Feb 16, 2022
1 parent aa85e48 commit de0d9ce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/api/c++/z3++.h
Original file line number Diff line number Diff line change
Expand Up @@ -3939,10 +3939,6 @@ namespace z3 {

Z3_solver_callback cb { nullptr };

context& ctx() {
return c ? *c : s->ctx();
}

struct scoped_cb {
user_propagator_base& p;
scoped_cb(void* _p, Z3_solver_callback cb):p(*static_cast<user_propagator_base*>(_p)) {
Expand Down Expand Up @@ -4005,6 +4001,10 @@ namespace z3 {

virtual ~user_propagator_base() = default;

context& ctx() {
return c ? *c : s->ctx();
}

/**
\brief user_propagators created using \c fresh() are created during
search and their lifetimes are restricted to search time. They should
Expand Down
5 changes: 3 additions & 2 deletions src/smt/theory_user_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ theory * theory_user_propagator::mk_fresh(context * new_ctx) {
if ((bool)m_final_eh) th->register_final(m_final_eh);
if ((bool)m_eq_eh) th->register_eq(m_eq_eh);
if ((bool)m_diseq_eh) th->register_diseq(m_diseq_eh);
if ((bool)m_created_eh) th->register_created(m_created_eh);
return th;
}

Expand Down Expand Up @@ -228,8 +229,8 @@ bool theory_user_propagator::internalize_term(app* term) {

add_expr(term);

if (!m_created_eh && (m_fixed_eh || m_eq_eh || m_diseq_eh))
throw default_exception("You have to register a created event handler for new terms if you track them");
if (!m_created_eh && (m_fixed_eh || m_eq_eh || m_diseq_eh))
return true;
if (m_created_eh)
m_created_eh(m_user_context, this, term);
return true;
Expand Down

0 comments on commit de0d9ce

Please sign in to comment.