Skip to content

Conversation

@arnavk23
Copy link
Contributor

@arnavk23 arnavk23 commented Jan 9, 2026

Fixes missing variable/stretches when the replacement DAG carries declarations (e.g., for control-flow conditions/targets).
Adds tests for input-vars and captured/declared-vars transfer.
Includes a release note.
Closes #15509.

…ixes Qiskit#15509)\n\n- Add input/captured/declared vars and stretches from replacement DAG\n- Add tests verifying input vars and captured/declared vars transfer\n- Add release note entry
@arnavk23 arnavk23 requested a review from a team as a code owner January 9, 2026 22:29
@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Jan 9, 2026
@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

@arnavk23 arnavk23 changed the title dagcircuit: transfer DAG-level variables in substitute_node_with_dag (fixes #15509) dagcircuit: transfer DAG-level variables in substitute_node_with_dag Jan 9, 2026
@arnavk23 arnavk23 changed the title dagcircuit: transfer DAG-level variables in substitute_node_with_dag dagcircuit: transfer DAG-level variables in substitute_node_with_dag Jan 9, 2026
Previously, substitute_node_with_dag() would try to add all variables
from the replacement DAG, including those already present in the target
DAG. This violated the constraint that a DAG cannot have both input and
captured variables simultaneously when the same variable object appears
in both contexts.

Now check if each variable is already present before adding it, matching
the behavior of compose() with inline_captures=False.
@coveralls
Copy link

coveralls commented Jan 9, 2026

Pull Request Test Coverage Report for Build 21118635002

Details

  • 15 of 25 (60.0%) changed or added relevant lines in 1 file are covered.
  • 30 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-0.03%) to 87.912%

Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/circuit/src/dag_circuit.rs 15 25 60.0%
Files with Coverage Reduction New Missed Lines %
crates/circuit/src/parameter/parameter_expression.rs 1 87.09%
crates/qasm2/src/lex.rs 8 91.52%
crates/circuit/src/parameter/symbol_expr.rs 9 72.96%
crates/qasm2/src/parse.rs 12 96.15%
Totals Coverage Status
Change from base Build 21112220188: -0.03%
Covered Lines: 100176
Relevant Lines: 113950

💛 - Coveralls

@arnavk23
Copy link
Contributor Author

@Cryoris can you please review this pr. I would really appreciate it. Thanks!

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

Status: No status

Development

Successfully merging this pull request may close these issues.

DAGCircuit.substitute_node_with_dag() does not handle DAG-level variable declarations

3 participants