Skip to content

Bug in qasm2.loads with if statement #249

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

Open
david-pl opened this issue May 7, 2025 · 0 comments
Open

Bug in qasm2.loads with if statement #249

david-pl opened this issue May 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@david-pl
Copy link
Collaborator

david-pl commented May 7, 2025

MRE:

from bloqade import qasm2
import textwrap

qasm2_prog = textwrap.dedent(
    """
    OPENQASM 2.0;
    include "qelib1.inc";
    qreg q[1];
    creg c[1];

    if(c == 1) x q[0];
    """
)

main = qasm2.loads(qasm2_prog)

The frame seems to "lose" all previous definitions when lowering the if statement.
I've narrowed it down to this point in the code:

with state.frame(node.body, region=frame.curr_region) as if_frame:

The self.current_frame.defs is not passed into the state.frame(...) and so later on it can't find q when lowering the if body.

@Roger-luo I think I'll need your help with this one.

@david-pl david-pl added the bug Something isn't working label May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant