Skip to content

feat: Add error context when lowering hugrs to LLVM#2869

Merged
aborgna-q merged 1 commit intomainfrom
ab/llvm-error-ctx
Feb 10, 2026
Merged

feat: Add error context when lowering hugrs to LLVM#2869
aborgna-q merged 1 commit intomainfrom
ab/llvm-error-ctx

Conversation

@aborgna-q
Copy link
Copy Markdown
Collaborator

@aborgna-q aborgna-q commented Feb 10, 2026

Because

thread 'emit::test::test_fns::tail_loop_exec::case_1' (101506913) panicked at hugr-llvm/src/test.rs:173:92:
called `Result::unwrap()` on an `Err` value: Unknown type: int(6)

is a useless error when it happens deeply nested inside some other workflow.

This PR adds some anyhow contexts, so the error now shows

thread 'emit::test::test_fns::tail_loop_exec::case_1' (101503258) panicked at hugr-llvm/src/test.rs:173:92:
called `Result::unwrap()` on an `Err` value: Failed to emit LLVM for function 'main' at node Node(1)

Caused by:
    No mapping found for type: int(6)

See Quantinuum/hugr-qir#218 for an example happening in the wild.

@aborgna-q aborgna-q requested a review from a team as a code owner February 10, 2026 14:08
@aborgna-q aborgna-q requested a review from cqc-alec February 10, 2026 14:08
@codecov
Copy link
Copy Markdown

codecov bot commented Feb 10, 2026

Codecov Report

❌ Patch coverage is 0% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.67%. Comparing base (4c2fbc6) to head (baed690).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
hugr-llvm/src/emit.rs 0.00% 3 Missing and 1 partial ⚠️
hugr-llvm/src/emit/ops.rs 0.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2869      +/-   ##
==========================================
- Coverage   83.69%   83.67%   -0.02%     
==========================================
  Files         266      266              
  Lines       53326    53333       +7     
  Branches    47580    47587       +7     
==========================================
  Hits        44629    44629              
- Misses       6291     6297       +6     
- Partials     2406     2407       +1     
Flag Coverage Δ
python 88.37% <ø> (ø)
rust 83.11% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

let (new_self, new_tasks) = self.emit_func_impl(func)?;
let (new_self, new_tasks) = self.emit_func_impl(func).with_context(|| {
format!(
"Failed to emit LLVM for function {} at node {next_node}",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add "with optype..." here, as we do above?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're already saying it's a function, and in most cases the function node itself will be supported, and the actual missing op/type will have its own message.

@aborgna-q aborgna-q added this pull request to the merge queue Feb 10, 2026
Merged via the queue into main with commit 48d76d4 Feb 10, 2026
32 of 33 checks passed
@aborgna-q aborgna-q deleted the ab/llvm-error-ctx branch February 10, 2026 14:41
@hugrbot hugrbot mentioned this pull request Feb 10, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 20, 2026
## 🤖 New release

* `hugr-model`: 0.25.5 -> 0.25.6 (✓ API compatible changes)
* `hugr-core`: 0.25.5 -> 0.25.6 (✓ API compatible changes)
* `hugr-llvm`: 0.25.5 -> 0.25.6 (✓ API compatible changes)
* `hugr-passes`: 0.25.5 -> 0.25.6 (✓ API compatible changes)
* `hugr`: 0.25.5 -> 0.25.6 (✓ API compatible changes)
* `hugr-cli`: 0.25.5 -> 0.25.6 (✓ API compatible changes)
* `hugr-persistent`: 0.4.5 -> 0.4.6

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr-model`

<blockquote>

##
[0.25.6](hugr-model-v0.25.5...hugr-model-v0.25.6)
- 2026-02-20

### New Features

- Remove size limitation for binary envelopes
([#2880](#2880))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.25.6](hugr-core-v0.25.5...hugr-core-v0.25.6)
- 2026-02-20

### Bug Fixes

- Canonicalize more
([#2839](#2839))
- used_extensions should include transitive requirements
([#2891](#2891))

### New Features

- Add s expression format to envelope formats
([#2864](#2864))
- added hash.rs, updated imports
([#2840](#2840))
- *(hugr-py)* Define typed Metadata protocol
([#2765](#2765))
- Add a `NodeTemplate::call_to_function` helper
([#2878](#2878))
- Remove size limitation for binary envelopes
([#2880](#2880))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.25.6](hugr-llvm-v0.25.5...hugr-llvm-v0.25.6)
- 2026-02-20

### New Features

- Add error context when lowering hugrs to LLVM
([#2869](#2869))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.25.6](hugr-passes-v0.25.5...hugr-passes-v0.25.6)
- 2026-02-20

### Bug Fixes

- Panic on UntuplePass when nodes had order edges
([#2883](#2883))

### New Features

- added hash.rs, updated imports
([#2840](#2840))
- Add a `NodeTemplate::call_to_function` helper
([#2878](#2878))
</blockquote>

## `hugr`

<blockquote>

##
[0.25.6](hugr-v0.25.5...hugr-v0.25.6)
- 2026-02-20

### Bug Fixes

- Panic on UntuplePass when nodes had order edges
([#2883](#2883))
- Canonicalize more
([#2839](#2839))
- used_extensions should include transitive requirements
([#2891](#2891))

### New Features

- Add s expression format to envelope formats
([#2864](#2864))
- *(hugr-py)* Define typed Metadata protocol
([#2765](#2765))
- Add a `NodeTemplate::call_to_function` helper
([#2878](#2878))
- added hash.rs, updated imports
([#2840](#2840))
- Remove size limitation for binary envelopes
([#2880](#2880))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.25.6](hugr-cli-v0.25.5...hugr-cli-v0.25.6)
- 2026-02-20

### New Features

- Add s expression format to envelope formats
([#2864](#2864))
</blockquote>

## `hugr-persistent`

<blockquote>

##
[0.4.0](hugr-persistent-v0.3.4...hugr-persistent-v0.4.0)
- 2025-12-22

### New Features

- [**breaking**] Remove `RootCheckable`
([#2704](#2704))
- [**breaking**] Bump MSRV to Rust 1.89
([#2747](#2747))
- [**breaking**] Type-safe access for node metadata
([#2755](#2755))

### Refactor

- [**breaking**] Remove multiple deprecated definitions
([#2751](#2751))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
@hugrbot hugrbot mentioned this pull request Feb 27, 2026
github-merge-queue bot pushed a commit that referenced this pull request Mar 6, 2026
## 🤖 New release

* `hugr-model`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-core`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-llvm`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-passes`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-persistent`: 0.4.6 -> 0.4.7 (✓ API compatible changes)
* `hugr`: 0.25.6 -> 0.25.7 (✓ API compatible changes)
* `hugr-cli`: 0.25.6 -> 0.25.7 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `hugr-model`

<blockquote>

##
[0.25.6](hugr-model-v0.25.5...hugr-model-v0.25.6)
- 2026-02-20

### New Features

- Remove size limitation for binary envelopes
([#2880](#2880))
</blockquote>

## `hugr-core`

<blockquote>

##
[0.25.7](hugr-core-v0.25.6...hugr-core-v0.25.7)
- 2026-03-06

### Documentation

- added examples in docs srtring
([#2920](#2920))
</blockquote>

## `hugr-llvm`

<blockquote>

##
[0.25.6](hugr-llvm-v0.25.5...hugr-llvm-v0.25.6)
- 2026-02-20

### New Features

- Add error context when lowering hugrs to LLVM
([#2869](#2869))
</blockquote>

## `hugr-passes`

<blockquote>

##
[0.25.7](hugr-passes-v0.25.6...hugr-passes-v0.25.7)
- 2026-03-06

### Documentation

- added examples in docs srtring
([#2920](#2920))

### New Features

- Define pass application scopes
([#2772](#2772))
- Modify dead code elimination pass to remove unreachable basic blocks
([#2884](#2884))
- Add non-generic `with_scope` method for composable passes
([#2910](#2910))
- update passes to use PassScope where non-breaking
([#2836](#2836))
</blockquote>

## `hugr-persistent`

<blockquote>

##
[0.4.0](hugr-persistent-v0.3.4...hugr-persistent-v0.4.0)
- 2025-12-22

### New Features

- [**breaking**] Remove `RootCheckable`
([#2704](#2704))
- [**breaking**] Bump MSRV to Rust 1.89
([#2747](#2747))
- [**breaking**] Type-safe access for node metadata
([#2755](#2755))

### Refactor

- [**breaking**] Remove multiple deprecated definitions
([#2751](#2751))
</blockquote>

## `hugr`

<blockquote>

##
[0.25.7](hugr-v0.25.6...hugr-v0.25.7)
- 2026-03-06

### Documentation

- added examples in docs srtring
([#2920](#2920))

### New Features

- Define pass application scopes
([#2772](#2772))
- Modify dead code elimination pass to remove unreachable basic blocks
([#2884](#2884))
- Add non-generic `with_scope` method for composable passes
([#2910](#2910))
- update passes to use PassScope where non-breaking
([#2836](#2836))
</blockquote>

## `hugr-cli`

<blockquote>

##
[0.25.6](hugr-cli-v0.25.5...hugr-cli-v0.25.6)
- 2026-02-20

### New Features

- Add s expression format to envelope formats
([#2864](#2864))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
@hugrbot hugrbot mentioned this pull request Mar 9, 2026
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