Skip to content

OpenQASM 3 exporter does not escape digits at the start of identifiers #15304

@jakelishman

Description

@jakelishman

Environment

  • Qiskit version: 2.2.3
  • Python version: 3.13
  • Operating system: macOS

What is happening?

The OQ3 exporter does not escape identifiers that start with an ASCII digit, even though this is invalid OQ3. The regex checking for valid identifiers is broken.

How can we reproduce the issue?

from qiskit import qasm3, QuantumCircuit, ClassicalRegister, QuantumRegister

qc = QuantumCircuit(QuantumRegister(3, name="3qr"), ClassicalRegister(2, name="2cr"))
print(qasm3.dumps(qc))
OPENQASM 3.0;
include "stdgates.inc";
bit[2] 2cr;
qubit[3] 3qr;

What should happen?

The register names should be escaped; they're invalid.

Any suggestions?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmod: qasm3Related to OpenQASM 3 import or export

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions