Skip to content

[BUG] qasm3_to_qir: "Variable c3 is not an array", despite c3 being an array. #44

@Sola85

Description

@Sola85

Environment

  • qBraid-QIR version: 0.2.3
  • Python version: 3.11.5
  • Operating system: Linux c5ce507e9ef3 5.15.153.1-microsoft-standard-WSL2

What happened?

The following Qiskit circuit is converted to qasm3 using qiskit.qasm3.

qubits = QuantumRegister(1)
clbits = ClassicalRegister(1)
circuit = QuantumCircuit(qubits, clbits)
(q0,) = qubits
(c0,) = clbits
 
circuit.h(q0)
circuit.measure(q0, c0)
with circuit.switch(c0) as case:
    with case(0):
        circuit.x(q0)
    with case(1):
        circuit.z(q0)
circuit.measure(q0, c0)

This yields the following QASM3:

OPENQASM 3.0;
include "stdgates.inc";
bit[1] c3;
int switch_dummy;
qubit[1] q3;
h q3[0];
c3[0] = measure q3[0];
switch_dummy = c3[0];
switch (switch_dummy) {
  case 0 {
    x q3[0];
  }
  case 1 {
    z q3[0];
  }
}
c3[0] = measure q3[0];

I get the following error message: qbraid_qir.qasm3.exceptions.Qasm3ConversionError: Indexing error. Variable c3 is not an array and Error at line 8, column 18 in QASM file.

I.e. the indexing c3[0] seems to fail.

Suggestions (Optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions