Skip to content

Fix: imports#103

Merged
acl-cqc merged 17 commits intomainfrom
acl/fix_imports
Mar 6, 2026
Merged

Fix: imports#103
acl-cqc merged 17 commits intomainfrom
acl/fix_imports

Conversation

@acl-cqc
Copy link
Collaborator

@acl-cqc acl-cqc commented Feb 27, 2026

Previously loadStmtsWithEnv was discarding the graph, but keeping the VEnv, from all previous modules (files). It was also reusing the same Namespace for each file....which in theory could lead to VEnv entries from earlier modules pointing to nodes in the graph from the current module.

Also change loadStmtsWithEnv to use combineDisjointEnv to protect against errors, and improve handling of failing compilation (which used to spit out some incomplete Hugrs) in test.

closes #13

@acl-cqc acl-cqc requested a review from croyzor February 27, 2026 21:13
@acl-cqc
Copy link
Collaborator Author

acl-cqc commented Feb 28, 2026

Update: I tried modifying main just to merge the old graph with the new in loadStmtsWithEnv, defining a new function combineGraphs that errors if the nodes have any common keys. This produces no new test fails, but occurs several times - always in merging the oldGraph with new, not kcGraph with the graph from the decl bodies. Specifically this happens for: teleportation, cqcconf, magic-state-distillation, klet, qft, rus, ising, vlup_covering, examples/arith (note there is also test/compilation/arith which is fine), imports. (All of these already xfailed for "other reasons"....)

So we could include that combineGraphs here to be defensive, but the sad thing is that we are combining graphs using <> which is just generic for tuples i.e. using <> for each element :(. Making Graph into an opaque ADT would be a good step but a lot of churn....

Also the combineGraphs error is not triggered in closures so still don't understand why that's fixed in the PR...

@croyzor
Copy link
Collaborator

croyzor commented Mar 2, 2026

I don't think this solves #96, but very likely that it is the problem behind #101!

@croyzor
Copy link
Collaborator

croyzor commented Mar 2, 2026

I've refactored combineDisjointEnvs a bit more to return a machine-usable error, which we can use to gather the FC in Load.hs (where we have the VDecl available - but not in checker). This could do with a test.

I'm struggling to come up with something where the error in Checker isn't raised first...

@croyzor croyzor self-requested a review March 3, 2026 12:06
@acl-cqc acl-cqc merged commit 6cf6b0d into main Mar 6, 2026
1 check passed
@acl-cqc acl-cqc deleted the acl/fix_imports branch March 6, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Importing functions from other modules changes the hugr output

2 participants