-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
RustThis PR or issue is related to Rust code in the repositoryThis PR or issue is related to Rust code in the repositorybugSomething isn't workingSomething isn't workingmod: qasm2Relating to OpenQASM 2 import or exportRelating to OpenQASM 2 import or export
Milestone
Description
Environment
- Qiskit Terra version: 0.25.0
- Python version: 3.10.8
- Operating system:
What is happening?
If there is a comment as the last line of the OpenQasm 2, the from_qasm_str
fails with the next error:
Traceback (most recent call last):
Cell In[16], line 27
QuantumCircuit.from_qasm_str(qasm_end_comment) # <- fails
File /opt/conda/lib/python3.10/site-packages/qiskit/circuit/quantumcircuit.py:2537 in from_qasm_str
return qasm2.loads(
File /opt/conda/lib/python3.10/site-packages/qiskit/qasm2/__init__.py:452 in loads
return _parse.from_bytecode(
File /opt/conda/lib/python3.10/site-packages/qiskit/qasm2/parse.py:214 in from_bytecode
for op in bc:
QASM2ParseError: '<input>:10,1: needed a start-of-statement token, but instead got /'
This was working in previous versions of Qiskit (can't confirm which version introduced the error).
How can we reproduce the issue?
from qiskit import QuantumCircuit
qasm_end_comment = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
//comment"""
qasm_end_blank_line= """
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
//comment
"""
QuantumCircuit.from_qasm_str(qasm_end_comment) # <- fails
QuantumCircuit.from_qasm_str(qasm_end_blank_line) # <- works
What should happen?
The OpenQasm is valid, so it should convert it to OpenQasm 2.0.
Any suggestions?
No response
Metadata
Metadata
Assignees
Labels
RustThis PR or issue is related to Rust code in the repositoryThis PR or issue is related to Rust code in the repositorybugSomething isn't workingSomething isn't workingmod: qasm2Relating to OpenQASM 2 import or exportRelating to OpenQASM 2 import or export