Hack around recursive operations calls
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
**Describe the bug**
When calling recursive operations in Base profile you get an error (this the correct behavior).
But you can get around it using the following hack. And it runs.
```
namespace TopLevel {
@EntryPoint()
operation Main() : Unit {
RecursiveOperation(0);
}
operation RecursiveOperation(x: Int) : Unit {
use q = Qubit();
Message($"Depth {x}");
let hack = [RecursiveOperation];
hack[0](x + 1);
}
}
```
**To Reproduce**
Steps to reproduce the behavior:
1. Open the playground on the latest main branch.
2. Paste the source code provided above.
3. Change the profile to Base.
4. Click on Run.
5. You will see that the code runs and prints some Messages.
6. Now go to the QIR tab, you will see "Error: memory access out of bounds".
**Expected behavior**
Describe what you expect to happen, versus what actually happened.
**Screenshots**
Correct behavior

Hack

**System information**
- Version of the package or extension for which the problem occurs: latest main branch
- Your operating system: Windows 11
- For issues with extensions, the version of the IDE for which the problem occurs: Playground
Contributor guide
Research direction
Start in the Playground with the supplied Q# reproduction, using the Base profile and checking both the run output and the QIR tab. Trace how the recursive operation is represented through the indirect array call and compare it with the direct recursive-call diagnostic. Done means the workaround is handled consistently without allowing invalid execution or producing an out-of-bounds QIR failure.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, quantum-computing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100