Skip to content
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

Unwrap panic on SimpleReplace #1323

Closed
aborgna-q opened this issue Jul 17, 2024 · 0 comments · Fixed by #1324
Closed

Unwrap panic on SimpleReplace #1323

aborgna-q opened this issue Jul 17, 2024 · 0 comments · Fixed by #1324
Assignees
Labels
bug Something isn't working

Comments

@aborgna-q
Copy link
Collaborator

While trying to replace the two nodes in the middle of this diagram

graph LR
    subgraph 0 ["(0) DFG"]
        direction LR
        1["(1) Input"]
        2["(2) Output"]
        3["(3) MakeTuple"]
        4["(4) UnpackTuple"]
        1--"0:0<br>[]+[]"-->3
        1--"1:1<br>[]+[]"-->3
        3--"0:0<br>[[]+[], []+[]]"-->4
        3--"0:2<br>[[]+[], []+[]]"-->2
        4--"0:0<br>[]+[]"-->2
        4--"1:1<br>[]+[]"-->2
    end
Loading

with this graph

graph LR
    subgraph 0 ["(0) DFG"]
        direction LR
        1["(1) Input"]
        2["(2) Output"]
        3["(3) MakeTuple"]
        1--"0:0<br>[]+[]"-->3
        1--"0:0<br>[]+[]"-->2
        1--"1:1<br>[]+[]"-->3
        1--"1:1<br>[]+[]"-->2
        3--"0:2<br>[[]+[], []+[]]"-->2
    end
Loading

I got an unwrap panic on SimpleReplacement::apply:158

I wrote a pure-hugr failing test in

fn test_half_nots(
dfg_hugr_half_not_bools: (Hugr, Vec<Node>),

@aborgna-q aborgna-q added the bug Something isn't working label Jul 17, 2024
@aborgna-q aborgna-q self-assigned this Jul 17, 2024
github-merge-queue bot pushed a commit that referenced this issue Jul 19, 2024
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.

---------

Co-authored-by: Douglas Wilson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant