Skip to content

Conversation

@akhil-102
Copy link

I've fixed this issue! The OpenQASM 3 exporter now correctly includes type annotations for for-loop variables.

What was fixed:

  • Added int type annotation before loop variable names in for-loop statements
  • Updated all existing for-loop tests to expect the correct format

Before:

for _ in {0, 1} {
  x q[0];
}

After:

for int param in {0, 1} {
  x q[0];
}

The fix ensures compliance with the OpenQASM 3 specification, which requires explicit type annotations for loop variables. This works for both named parameters (like param) and unnamed parameters (which use _).

Add type annotation to for-loop variables in OpenQASM 3 output.
Loop variables now correctly include 'int' type annotation as required
by the OpenQASM 3 specification.

Fixes Qiskit#12866
@akhil-102 akhil-102 requested a review from a team as a code owner December 26, 2025 07:24
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Dec 26, 2025
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

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

  • @Qiskit/terra-core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PR PRs from contributors that are not 'members' of the Qiskit repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants