qiskit icon indicating copy to clipboard operation
qiskit copied to clipboard

Fix OpenQASM 2 `gate` definitions following a shadowed built-in `gate`

Open jakelishman opened this issue 1 year ago • 2 comments

Summary

Previously, when given an OpenQASM 2 program such as

OPENQASM 2.0;
gate builtin a { U(0, 0, 0) a; }
gate not_builtin a { U(pi, pi, pi) a; }
qreg q[1];

not_builtin q[0];

and a set of custom_instructions including a builtin=True definition for builtin (but not for not_builtin), the Rust and Python sides would get themselves out-of-sync and output a gate that matched a prior definition, rather than not_builtin.

This was because the Rust side was still issuing DefineGate bytecode instructions, even for gates whose OpenQASM 2 definitions should have been ignored, so Python-space thought there were more gates than Rust-space thought there were.

Details and comments

Fix #13339.

jakelishman avatar Oct 17 '24 14:10 jakelishman

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

qiskit-bot avatar Oct 17 '24 14:10 qiskit-bot

Pull Request Test Coverage Report for Build 11386911964

Details

  • 6 of 6 (100.0%) changed or added relevant lines in 1 file are covered.
  • 22 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.02%) to 88.643%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 91.98%
crates/qasm2/src/parse.rs 18 96.69%
<!-- Total: 22
Totals Coverage Status
Change from base Build 11383196578: -0.02%
Covered Lines: 73174
Relevant Lines: 82549

💛 - Coveralls

coveralls avatar Oct 17 '24 14:10 coveralls