push
github
Fix empty-barrier handling in OpenQASM 2 (#10469) (#10491) The new parser would allow a `barrier;` statement, implicitly broadcasting it across all qubits in scope. This is technically not supported by the OpenQASM 2 specification, but is a useful quality-of-life extension to the specification (in the same way that Qiskit interprets barriers, and the OpenQASM 3 specification defines the `barrier;` statement). The precise rule is added to the new parser's `strict` mode. The OpenQASM 2 _exporter_ similarly should not have been putting out `barrier;` statements. These could only occur in Qiskit when a barrier was explicitly constructed with zero elements (as opposed to the call `QuantumCircuit.barrier()`, which has the all-in-scope behaviour), and consequently have no actual meaning or effect. The exporter is modified to simply skip such instructions, for as long as Qiskit permits the qubitless barrier statement. (cherry picked from commit e75893d45) Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
11 of 11 new or added lines in 2 files covered. (100.0%)
72889 of 84842 relevant lines covered (85.91%)
60196.7 hits per line