Skip to content

Commit c9689a2

Browse files
authored
Fixed a bug that lead to the leaking of Symbols in the objective function. (#37)
Prior to this fix, whenever an `EQ` constraint was added, after being removed, it would always lead to a lingering Symbol on the `objective`. This was caused by a single `else` keyword, which prevented both `Error` `Symbol`s from being removed, even though neither would be needed anymore. I noticed this bug when I tried to repeatedly add and remove `Constraint`s from the `Solver` over and over again, and I noticed through debugging that, although every other member of the `Solver` kept a steady size, the `objective` just seemed to keep growing no matter what. This was caused by an assymetry when removing `Error` `Symbol`s from `EQ` constraints. This PR fixes this assimetry. I would appreciate if this could be merged and a new version of `kasuari` could be created, so I don't have to post my own on `crates.io`
1 parent 1c16c27 commit c9689a2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/solver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ impl Solver {
781781
fn remove_constraint_effects(&mut self, constraint: &Constraint, tag: &Tag) {
782782
if tag.marker.kind() == SymbolKind::Error {
783783
self.remove_marker_effects(tag.marker, constraint.strength().value());
784-
} else if tag.other.kind() == SymbolKind::Error {
784+
}
785+
if tag.other.kind() == SymbolKind::Error {
785786
self.remove_marker_effects(tag.other, constraint.strength().value());
786787
}
787788
}

0 commit comments

Comments
 (0)