feat: Do resolution while computing used_extensions#2834
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2834 +/- ##
==========================================
+ Coverage 83.64% 83.69% +0.04%
==========================================
Files 261 261
Lines 52842 53047 +205
Branches 47374 47374
==========================================
+ Hits 44200 44397 +197
- Misses 6253 6261 +8
Partials 2389 2389
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:
|
|
Fixed |
d8b36d3 to
94dab1e
Compare
ss2165
left a comment
There was a problem hiding this comment.
Partial review (short on time) but there is a major comment which you may want to address before an in-depth review anyway
| op = self[node].op | ||
| # _resolve_used_extensions returns the resolved op and the extensions | ||
| resolved_op, reg = op._resolve_used_extensions(resolve_from) | ||
| if resolved_op is not op: |
There was a problem hiding this comment.
why the if guard, still an identity no?
There was a problem hiding this comment.
Not for this case in particular, but I had if ... is not ... to avoid re-creating the frozen containers.
But I shouldn't be doing those optimizations here. I removed all those checks.
| self, registry: ExtensionRegistry | None = None | ||
| ) -> ExtensionRegistry: | ||
| resolved_ty, reg = self.ty._resolve_used_extensions(registry) | ||
| assert isinstance(resolved_ty, Array) |
There was a problem hiding this comment.
| assert isinstance(resolved_ty, Array) | |
| assert isinstance(resolved_ty, Array), "HUGR internal error, expected resolved type to be array." |
There was a problem hiding this comment.
Added similar messages to all the asserts
3a31e37 to
e03afb4
Compare
Co-authored-by: Seyon Sivarajah <seyon.sivarajah@quantinuum.com>
🤖 I have created a release *beep* *boop* --- ## [0.15.1](hugr-py-v0.15.0...hugr-py-v0.15.1) (2026-01-28) ### Features * Add used_extensions method to Hugr ([#2817](#2817)) ([0d88a43](0d88a43)), closes [#2614](#2614) * Do resolution while computing used_extensions ([#2834](#2834)) ([7aff29e](7aff29e)) * **py:** add qualified_name method to TypeDef ([#2804](#2804)) ([b2231b3](b2231b3)), closes [#2426](#2426) ### Bug Fixes * add register_updated function for registry for self-referential ops ([#2830](#2830)) ([afba54f](afba54f)), closes [#2829](#2829) --- 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 <agustin.borgna@quantinuum.com>
…#1371) We'll need this for #1368, now that hugr is getting extension resolution (Quantinuum/hugr#2834).
… passes (#1372) Fixes #1368 by ensuring we bundle any additional extension in the packages sent to the rust side. - [x] Requires #1371 - [x] Requires Quantinuum/hugr#2834. ~I'm keeping this as a draft until that patch is released.~ - [x] Requires #1379 --------- Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Replaces the unpublished
used_extensionsmethods on types and ops with an internal_resolve_used_extensionsthatops.Customwithops.ExtOps andtys.Opaquewithtys.ExtTypes that point to their resolved extension definition.This is necessary to solve Quantinuum/guppylang#1451 and Quantinuum/tket2#1368.
Hugr.used_extensionsnow has an optionalresolve_fromparameter.Hugr.resolve_extensionshas been deprecated.