3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-22 16:27:37 +00:00

Merge pull request #8655 from Z3Prover/copilot/fix-go-bindings-reference-count

[WIP] Fix reference counting for Z3_ast_vector in go bindings
This commit is contained in:
Nikolaj Bjorner 2026-02-16 13:58:03 -08:00 committed by GitHub
commit 1fb405cf44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 30 deletions

View file

@ -135,23 +135,13 @@ func (s *Solver) NumScopes() uint {
// Assertions returns the assertions in the solver.
func (s *Solver) Assertions() []*Expr {
vec := C.Z3_solver_get_assertions(s.ctx.ptr, s.ptr)
size := uint(C.Z3_ast_vector_size(s.ctx.ptr, vec))
result := make([]*Expr, size)
for i := uint(0); i < size; i++ {
result[i] = newExpr(s.ctx, C.Z3_ast_vector_get(s.ctx.ptr, vec, C.uint(i)))
}
return result
return astVectorToExprs(s.ctx, vec)
}
// UnsatCore returns the unsat core if the constraints are unsatisfiable.
func (s *Solver) UnsatCore() []*Expr {
vec := C.Z3_solver_get_unsat_core(s.ctx.ptr, s.ptr)
size := uint(C.Z3_ast_vector_size(s.ctx.ptr, vec))
result := make([]*Expr, size)
for i := uint(0); i < size; i++ {
result[i] = newExpr(s.ctx, C.Z3_ast_vector_get(s.ctx.ptr, vec, C.uint(i)))
}
return result
return astVectorToExprs(s.ctx, vec)
}
// ReasonUnknown returns the reason why the result is unknown.