check: drop facts before/after an IOManip

This commit is contained in:
Nigel Tao committed 2024-02-09 15:31:50 +11:00
1 parent e5dc87e4d3
commit 569a91892e
2 files changed
+12 -8

No files matched your search

+9
View File
@@ -84,6 +84,15 @@ func (z *facts) appendFact(fact *a.Expr) {
*z = append(*z, fact)
}
func (z *facts) dropAnyFactsMentioning(n *a.Expr) error {
return z.update(func(x *a.Expr) (*a.Expr, error) {
if x.Mentions(n) {
return nil, nil
}
return x, nil
})
}
// update applies f to each fact, replacing the slice element with the result
// of the function call. The slice is then compacted to remove all nils.
func (z *facts) update(f func(*a.Expr) (*a.Expr, error)) error {