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

feat!: Cleaner error on wiring errors while building #873

Merged
merged 4 commits into from
Mar 11, 2024

Conversation

aborgna-q
Copy link
Collaborator

Adds a new BuilderWiringError, that gets wrapper under either BuildError::OutputWiring or BuildError::OperationWiring when passing a wrong set of input wires to a builder method.

The goal of this is to report useful information about the errors to the user.
Now we can give a bit more context, including the location in the hugr.

Compare the old error:

Can't copy linear type: Type(Extension(CustomType { extension: IdentList("prelude"), id: "qubit", args: [], bound: Any }), Any).

With:

Found an error while setting the outputs of a FuncDefn container, Node(1). Cannot copy linear type qubit from output Port(Outgoing, 0) of node Node(2)

Although the have the location of the error, we may still not have access to the Hugr being built (e.g. if calling finish_hugr). I'll open an issue for addressing that.

Updated methods that could only return `Err` on internal bugs.
@aborgna-q aborgna-q requested a review from cqc-alec March 11, 2024 14:28
Base automatically changed from feat/infallible-container-methods to main March 11, 2024 15:55
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 86.79245% with 7 lines in your changes are missing coverage. Please review.

Project coverage is 85.73%. Comparing base (3419fba) to head (9af3a5f).

Files Patch % Lines
quantinuum-hugr/src/builder/build_traits.rs 86.36% 4 Missing and 2 partials ⚠️
quantinuum-hugr/src/builder.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #873   +/-   ##
=======================================
  Coverage   85.73%   85.73%           
=======================================
  Files          78       78           
  Lines       14408    14427   +19     
  Branches    14408    14427   +19     
=======================================
+ Hits        12352    12369   +17     
- Misses       1418     1420    +2     
  Partials      638      638           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@aborgna-q aborgna-q added this pull request to the merge queue Mar 11, 2024
Merged via the queue into main with commit 2c1539c Mar 11, 2024
10 checks passed
@aborgna-q aborgna-q deleted the feat/builder-wiring-error branch March 11, 2024 16:09
@github-actions github-actions bot mentioned this pull request Mar 11, 2024
@github-actions github-actions bot mentioned this pull request Apr 15, 2024
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.

2 participants