When using qasm3.dumps to output QASM3 strings, an issue arises when a while loop with a condition of 0 is encountered. The generated QASM3 string contains a "!" character as part of the condition, which subsequently leads to an error during the loading of the QASM3 code.
To address the issue of the "!" character causing errors during loading, an alternative approach can be explored. This approach involves modifying the qasm3.loads function to handle the "!" character appropriately. By extending the functionality of the qasm3.loads function, it would be possible to interpret and process the "!" character within the while loop condition, preventing unhandled unary operator errors.
Steps to Reproduce
Execute the provided Python code snippet that uses qasm3.dumps to generate a QASM3 string containing a while loop with a 0 condition.
Attempt to load the generated QASM3 string using the qasm3.loads function.
Thanks for the report. Yeah, I haven't updated the OpenQASM 3 importer to take into account all the newly supported parts of Qiskit Terra 0.25 yet (Qiskit 0.44) yet, but I need to.
When using qasm3.dumps to output QASM3 strings, an issue arises when a while loop with a condition of 0 is encountered. The generated QASM3 string contains a "!" character as part of the condition, which subsequently leads to an error during the loading of the QASM3 code.
Code Example
Generated QASM3 Code:
Attempting to Load QASM3 Code:
Error Message:
Expected Behavior
To address the issue of the "!" character causing errors during loading, an alternative approach can be explored. This approach involves modifying the
qasm3.loads
function to handle the "!" character appropriately. By extending the functionality of theqasm3.loads
function, it would be possible to interpret and process the "!" character within the while loop condition, preventing unhandled unary operator errors.Steps to Reproduce
Execute the provided Python code snippet that uses qasm3.dumps to generate a QASM3 string containing a while loop with a 0 condition. Attempt to load the generated QASM3 string using the
qasm3.loads
function.Additional Information
qiskit
Version: 0.44.0openqasm3
Version: 0.4.0qiskit_qasm3_import
Version: 0.2.0Python
Version: 3.9.7