From c4154cbb0e8e56d351d012eb284c34424821e25a Mon Sep 17 00:00:00 2001 From: Innokentii Sennovskii Date: Tue, 9 Jul 2024 14:16:30 +0100 Subject: [PATCH] fix: Fix issue with unresolved results (#5453) # Description ## Problem\* check_for_underconstrained_values pass was producing false positives because the value ids of results in the function were different from the value ids used in other constraints and had to be resolved. ## Summary\* Added checks to ensure we also resolve all values before using ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [ ] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- .../src/ssa/checks/check_for_underconstrained_values.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs b/compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs index 6dac99d7a09..5831faa7c4d 100644 --- a/compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs +++ b/compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs @@ -105,7 +105,7 @@ impl Context { .iter() .chain(function.returns()) .filter(|id| function.dfg.get_numeric_constant(**id).is_none()) - .copied(); + .map(|value_id| function.dfg.resolve(*value_id)); let mut connected_sets_indices: HashSet = HashSet::new(); @@ -169,13 +169,13 @@ impl Context { // Insert non-constant instruction arguments function.dfg[*instruction].for_each_value(|value_id| { if function.dfg.get_numeric_constant(value_id).is_none() { - instruction_arguments_and_results.insert(value_id); + instruction_arguments_and_results.insert(function.dfg.resolve(value_id)); } }); // And non-constant results for value_id in function.dfg.instruction_results(*instruction).iter() { if function.dfg.get_numeric_constant(*value_id).is_none() { - instruction_arguments_and_results.insert(*value_id); + instruction_arguments_and_results.insert(function.dfg.resolve(*value_id)); } }