-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Panic on SimpleReplace
with multiports
#1324
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1324 +/- ##
==========================================
+ Coverage 87.31% 87.45% +0.13%
==========================================
Files 108 108
Lines 19784 19791 +7
Branches 17520 17527 +7
==========================================
+ Hits 17275 17308 +33
+ Misses 1724 1717 -7
+ Partials 785 766 -19
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement, thank you. I couple of minor nits, but do lmk if you disagree. Happy to approve when you're ready.
/// Returns the hugr and the nodes of the NOT gates, in order. | ||
#[fixture] | ||
pub(in crate::hugr::rewrite) fn dfg_hugr_half_not_bools() -> (Hugr, Vec<Node>) { | ||
fn build() -> Result<(Hugr, Vec<Node>), BuildError> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to not return a result, instead unwrap everywhere. This makes failures much easier to debug.
#[rstest] | ||
fn test_half_nots( | ||
dfg_hugr_half_not_bools: (Hugr, Vec<Node>), | ||
) -> Result<(), Box<dyn std::error::Error>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I prefer no Result.
|
||
let subgraph = SiblingSubgraph::try_from_nodes(vec![input_not, output_not_0], &hugr)?; | ||
// A map from (target ports of edges from the Input node of `replacement`) to (target ports of | ||
// edges from nodes not in `removal` to nodes in `removal`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm glad I'm not the only one who finds this v confusing
Co-authored-by: Douglas Wilson <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
## 🤖 New release * `hugr`: 0.8.0 -> 0.9.0 * `hugr-core`: 0.5.0 -> 0.6.0 * `hugr-passes`: 0.5.0 -> 0.6.0 * `hugr-cli`: 0.1.4 -> 0.2.0 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr` <blockquote> ## 0.9.0 (2024-07-19) ### Bug Fixes - Add op's extension to signature check in `resolve_opaque_op` ([#1317](#1317)) - Panic on `SimpleReplace` with multiports ([#1324](#1324)) ### Refactor - [**breaking**] Separate Signature from FuncValueType by parametrizing Type(/Row)/etc. ([#1138](#1138)) ### Testing - Verify order edges ([#1293](#1293)) - Add failing test case for [#1315](#1315) ([#1316](#1316)) </blockquote> ## `hugr-core` <blockquote> ## 0.6.0 (2024-07-19) ### Bug Fixes - Add op's extension to signature check in `resolve_opaque_op` ([#1317](#1317)) - Panic on `SimpleReplace` with multiports ([#1324](#1324)) ### Refactor - [**breaking**] Separate Signature from FuncValueType by parametrizing Type(/Row)/etc. ([#1138](#1138)) ### Testing - Verify order edges ([#1293](#1293)) - Add failing test case for [#1315](#1315) ([#1316](#1316)) </blockquote> ## `hugr-passes` <blockquote> ## 0.6.0 (2024-07-19) ### Refactor - [**breaking**] Separate Signature from FuncValueType by parametrizing Type(/Row)/etc. ([#1138](#1138)) </blockquote> ## `hugr-cli` <blockquote> ## 0.2.0 (2024-07-19) ### Refactor - [**breaking**] Separate Signature from FuncValueType by parametrizing Type(/Row)/etc. ([#1138](#1138)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/MarcoIeni/release-plz/). --------- Co-authored-by: Douglas Wilson <[email protected]>
Closes #416. Requires ~CQCL/hugr#1295 CQCL/hugr#1324 to be released.
Fixes #1323
This fix generalises the one from #1191.
SimpleReplace was too eager in disconnecting/connecting edges to the replacement graph, and that caused issues when querying the neighbours of multiports.
This gets resolved by delaying all new connections to the replacement until after we have computed all of them.
We don't need to do explicit disconnections to the replaced subgraph, since the nodes get removed anyway.