Skip to content

Enhance function call handling to support nested functions#245

Merged
TheGupta2012 merged 3 commits intomainfrom
nested-subroutines
Aug 14, 2025
Merged

Enhance function call handling to support nested functions#245
TheGupta2012 merged 3 commits intomainfrom
nested-subroutines

Conversation

@TheGupta2012
Copy link
Copy Markdown
Member

@TheGupta2012 TheGupta2012 commented Aug 13, 2025

Fixes #9

Summary of changes

Added support for nested functions by using qubit transformation for the whole stack of functions. Previously, we were only updating the qubit variables for the latest function call.

Function Call and Argument Handling Improvements

  • Added support for nested function calls, allowing functions to call other functions with quantum and classical arguments, including passing quantum registers and parameters through multiple layers of function calls. [1] [2]
  • Refactored quantum argument processing by introducing actual_qreg_size_map to accurately track the sizes of actual quantum registers passed to functions, ensuring correct mapping and transformation of qubit arguments. [1] [2] [3] [4] [5] [6]

Quantum Register Transformation

  • Updated the quantum register transformation logic in transform_function_qubits and related visitor methods to use both transformation maps and size maps, enabling correct qubit mapping across nested function scopes and supporting more complex function hierarchies. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]

… modularity and reusability in QASM programs. Update tests to validate new functionality.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@TheGupta2012 TheGupta2012 changed the title Enhance function call handling to support nested functions, Enhance function call handling to support nested functions Aug 13, 2025
@TheGupta2012 TheGupta2012 merged commit 5c61fb5 into main Aug 14, 2025
1 check passed
@TheGupta2012 TheGupta2012 deleted the nested-subroutines branch August 14, 2025 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add support for unrolling nested functions

2 participants