summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-06-16 10:21:53 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-06-16 10:21:53 -0400
commita5550d478234efbb89d1c23ae3234bed626a47f6 (patch)
tree66b0e99a670cc7043ee453fef4ddf6f969b4c76b
parent425956c9022fda1e98544c4b2d495e91dfde4b4f (diff)
downloadbfs-a5550d478234efbb89d1c23ae3234bed626a47f6.tar.xz
opt: Wait until purity is computed to update facts_when_impure
Since we moved purity out of the parser, side-effect detection has been unnecessarily pessimistic due to this bug. The fix restores warnings in cases like $ bfs -false bfs: warning: This command won't do anything. Fixes: 693b5f60dc9787d9237920cc0c87fe0e010194ee
-rw-r--r--src/opt.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/opt.c b/src/opt.c
index 4699af4..14de081 100644
--- a/src/opt.c
+++ b/src/opt.c
@@ -1225,10 +1225,6 @@ static struct bfs_expr *optimize_expr_recursive(struct opt_state *state, struct
return ret;
}
- if (!bfs_expr_is_parent(expr) && !expr->pure) {
- facts_union(state->facts_when_impure, state->facts_when_impure, &state->facts);
- }
-
expr = optimize_expr_lookup(state, expr);
if (!expr) {
return NULL;
@@ -1247,6 +1243,8 @@ static struct bfs_expr *optimize_expr_recursive(struct opt_state *state, struct
expr->ephemeral_fds = lhs->ephemeral_fds;
}
}
+ } else if (!expr->pure) {
+ facts_union(state->facts_when_impure, state->facts_when_impure, &state->facts);
}
if (expr->always_true) {