Skip to content

[BUG] Incorrect parsing of qubit in function #311

@TheGupta2012

Description

@TheGupta2012

Environment

  • PyQASM version: 1.0.1
  • Python version:
  • Operating system:

What happened?

The following code produced an unroll error -

from pyqasm import loads 
qasm = """
OPENQASM 3.0;
include "stdgates.inc";

qubit[2] q;
bit[2] c;

def my_gate(qubit q) {
  for int i in [0:3] {
    h q;
  }
}

my_gate(q[1]);
"""
mod = loads(qasm)
mod.unroll()
ERROR:pyqasm: Error at line 10, column 4 in QASM file

 >>>>>> h q[1]
.....
Failed to parse QASM: Index 1 out of range for register of size 1 in qubit

However, this works with a call to my_gate(q[0]).

Suggestions (Optional)

The qubit index is not being propagated correctly, should be 0 instead of 1 in the method definition

Metadata

Metadata

Assignees

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