From a5550d478234efbb89d1c23ae3234bed626a47f6 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 16 Jun 2023 10:21:53 -0400 Subject: 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 --- src/opt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/opt.c') 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) { -- cgit v1.2.3