Skip to content

[BUG] Error in function call with aliased qubit #108

@TheGupta2012

Description

@TheGupta2012

Environment

  • PyQASM version: 0.1.0
  • Python version: 3.11.6
  • Operating system: macOS 15.1.1

What happened?

Aliased qubit was not loaded as a function call argument -

In [1]: import pyqasm

In [2]: qasm_str = """
   ...: OPENQASM 3;
   ...: qubit[3] q;
   ...: 
   ...: def dummy(qubit[1] q_arg) -> bool { 
   ...:     h q_arg;
   ...:     return true;
   ...: }
   ...: 
   ...: for int i in [0:2]
   ...: {
   ...:    let new_q = q[i];
   ...:    dummy(new_q);
   ...: }
   ...: """
   ...: 
   ...: 
   ...: 
   ...: 

In [3]: module = pyqasm.loads(qasm_str)

In [4]: module.validate()
ERROR:root:Error at line 13, column 3 in QASM file

....
ValidationError: Expecting qubit argument for 'q_arg'. Qubit register 'new_q' not found for function 'dummy'

This should not happen and the actual qubit register i.e. q[i] should be propagated to the function call

Suggestions (Optional)

Most likely we need to check the alias map too while mapping formal quantum args to actual quantum args

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingqasm3Related to openqasm3

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions