Skip to content

Preserve releases on discarded qubit allocations - #3904

Open
Ian Davis (idavis) wants to merge 1 commit into
iadavis/pass-split/rca-controlled-argument-aliasesfrom
iadavis/pass-split/discarded-qubit-allocation
Open

Ian Davis (idavis) wants to merge 1 commit into
iadavis/pass-split/rca-controlled-argument-aliasesfrom
iadavis/pass-split/discarded-qubit-allocation

Conversation

@idavis

Copy link
Copy Markdown
Collaborator

Issue

The HIR qubit-allocation rewrite assumed that single-qubit and qubit-array allocations always used a named binding. Valid code such as use _ = Qubit(); or use _ = Qubit[2]; therefore triggered a compiler panic.

Discarding the source-level binding does not remove the allocation's lifetime: the compiler must retain a reference so it can release the qubits when their scope ends, including on early exits.

Fix

  • Generate a hidden local for discarded scalar and array allocations.
  • Register that local with the existing cleanup machinery, preserving normal scope-exit and early-return releases.
  • Leave named bindings and tuple-allocation behavior unchanged.

@idavis
Ian Davis (idavis) added this pull request to stack #3892 October 7, 2026 12:51
@idavis Ian Davis (idavis) changed the title preserve discarded qubit releases Preserve releases on discarded qubit allocations Oct 7, 2026

This branch has not been deployed

No deployments
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.

1 participant