fix: BorrowArray discard handler allows elements to be borrowed#2666
Merged
fix: BorrowArray discard handler allows elements to be borrowed#2666
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2666 +/- ##
==========================================
+ Coverage 83.41% 83.46% +0.04%
==========================================
Files 262 262
Lines 51176 51297 +121
Branches 46737 46858 +121
==========================================
+ Hits 42689 42813 +124
+ Misses 6109 6105 -4
- Partials 2378 2379 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1972949 to
d4e9638
Compare
d4e9638 to
de750c8
Compare
aborgna-q
approved these changes
Nov 5, 2025
Collaborator
aborgna-q
left a comment
There was a problem hiding this comment.
I had to add hugr-passes as a dev dependency of hugr-llvm
Should be fine, It makes more sense than testing llvm code on hugr-passes. If needed, we can move things to integration tests later.
I suggest we make the "drop" op public as part of some hugr-passes extension
Maybe open an issue?
Closed
Merged
github-merge-queue bot
pushed a commit
that referenced
this pull request
Nov 6, 2025
## 🤖 New release * `hugr-model`: 0.24.2 -> 0.24.3 (✓ API compatible changes) * `hugr-core`: 0.24.2 -> 0.24.3 * `hugr-llvm`: 0.24.2 -> 0.24.3 (✓ API compatible changes) * `hugr-passes`: 0.24.2 -> 0.24.3 (✓ API compatible changes) * `hugr`: 0.24.2 -> 0.24.3 (✓ API compatible changes) * `hugr-cli`: 0.24.2 -> 0.24.3 (✓ API compatible changes) * `hugr-persistent`: 0.3.3 -> 0.3.4 <details><summary><i><b>Changelog</b></i></summary><p> ## `hugr-model` <blockquote> ## [0.24.1](hugr-model-v0.24.0...hugr-model-v0.24.1) - 2025-11-03 ### Bug Fixes - Correct conversion of `table::Term::Tuple` to `ast::Term` ([#2653](#2653)) </blockquote> ## `hugr-core` <blockquote> ## [0.24.1](hugr-core-v0.24.0...hugr-core-v0.24.1) - 2025-11-03 ### Bug Fixes - validation outside entrypoint, normalize_cfgs w/ nonlocal edges ([#2633](#2633)) - SiblingSubgraph::try_from_nodes for non-entrypoint region ([#2655](#2655)) - Correct conversion of `table::Term::Tuple` to `ast::Term` ([#2653](#2653)) ### New Features - track package descriptions when loading ([#2639](#2639)) - *(cli)* describe sub-command ([#2650](#2650)) </blockquote> ## `hugr-llvm` <blockquote> ## [0.24.3](hugr-llvm-v0.24.2...hugr-llvm-v0.24.3) - 2025-11-06 ### Bug Fixes - BorrowArray discard handler allows elements to be borrowed ([#2666](#2666)) </blockquote> ## `hugr-passes` <blockquote> ## [0.24.3](hugr-passes-v0.24.2...hugr-passes-v0.24.3) - 2025-11-06 ### Bug Fixes - BorrowArray discard handler allows elements to be borrowed ([#2666](#2666)) </blockquote> ## `hugr` <blockquote> ## [0.24.3](hugr-v0.24.2...hugr-v0.24.3) - 2025-11-06 ### Bug Fixes - BorrowArray discard handler allows elements to be borrowed ([#2666](#2666)) </blockquote> ## `hugr-cli` <blockquote> ## [0.24.1](hugr-cli-v0.24.0...hugr-cli-v0.24.1) - 2025-11-03 ### New Features - track package descriptions when loading ([#2639](#2639)) - *(cli)* describe sub-command ([#2650](#2650)) </blockquote> ## `hugr-persistent` <blockquote> ## [0.3.2](hugr-persistent-v0.3.1...hugr-persistent-v0.3.2) - 2025-11-03 ### New Features - *(persistent)* More efficient HugrView iterators for PersistentHugr ([#2595](#2595)) </blockquote> </p></details> --- This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
github-merge-queue bot
pushed a commit
to Quantinuum/tket2
that referenced
this pull request
Nov 10, 2025
Looks like #1230 changed the snapshots, but my local wheel cache didn't update. This PR includes some fixes: - Update the pytest snapshots of qis-compiler, with the changes arising from Quantinuum/hugr#2666 and published in `hugr 0.23.4`. - Ensures that the required CI checks fail if `tests-qis-compiler` fails. (And makes sure we don't omit new requirements again). - Adds `update-snapshots-py` to the justfile
Merged
github-merge-queue bot
pushed a commit
to Quantinuum/tket2
that referenced
this pull request
Nov 10, 2025
🤖 I have created a release *beep* *boop* --- ## [0.2.10](qis-compiler-v0.2.9...qis-compiler-v0.2.10) (2025-11-10) ### Features * add GPU lowering to selene-hugr-qis-compiler ([#1169](#1169)) ([bcf1d4c](bcf1d4c)) ### Bug Fixes * Fix runtime panic when iterating through arrays of affine/bool types ([hugr#2666](Quantinuum/hugr#2666)) ([01b8a8e](01b8a8e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: Agustín Borgna <[email protected]> Co-authored-by: Agustín Borgna <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes Quantinuum/guppylang#1330
This is a mass of Hugr construction; the alternative of adding a new op to BorrowArray would do much the same in LLVM, and I don't think the increase in Hugr size should be very much - compared to a standard linear array discard, we have TailLoop rather than ArrayScan, with merely an extra conditional around the discarding of each element (and nodes moved into the main Hugr rather than a Value::Function, so it looks bigger).
Note there is no need to do this for BorrowArray::discard (the copyable-elements-only function), as that doesn't check borrowedness; copyable elements don't need discard functions so we just deallocate the lot without looking what's there.
I added hugr-passes as a dev dependency of hugr-llvm to get an execution test, and verified switching-round the senses of conditionals made this fail, which gives some confidence it's correct ;)