Environment
- PyQASM version: source
- Python version: 3.12.7
- Operating system: macOS 14.4
What happened?
The following qasm program passes unrolling -
In [1]: import pyqasm
In [2]: qasm_str = """
...: OPENQASM 3.0;
...: include "stdgates.inc";
...:
...: qubit[2] q;
...:
...: def custom_fn( qubit q1, qubit q2, qubit q3) -> bool {
...: h q1;
...: h q2;
...: h q3;
...: return true;
...: }
...:
...: bool result = custom_fn(q[0], q[1], q[1]);
...: """
In [3]: mod = pyqasm.loads(qasm_str)
In [4]: mod.unroll()
In [5]: mod.qasm_str().splitlines()
Out[5]:
['OPENQASM 3.0;',
'include "stdgates.inc";',
'qubit[2] q;',
'h q[0];',
'h q[1];',
'h q[1];']
but should have raised the error that we have duplicate qubit arguments present in the function call.
Suggestions (Optional)
- The
duplicate_qubit_detect_map should be updated across argument validation. Presently, it is only getting updated if a register name is not present.
- Moreover, the
validate_unique_qubits should have a more descriptive doc and moved to the Qasm3SubroutineProcessor because it is referred only inside the process_quantum_arg method
Environment
What happened?
The following qasm program passes unrolling -
but should have raised the error that we have duplicate qubit arguments present in the function call.
Suggestions (Optional)
duplicate_qubit_detect_mapshould be updated across argument validation. Presently, it is only getting updated if a register name is not present.validate_unique_qubitsshould have a more descriptive doc and moved to theQasm3SubroutineProcessorbecause it is referred only inside theprocess_quantum_argmethod