Attempt to generate controlled/adjoint variant when it is not requested
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
**Describe the bug**
I'm trying to pick a random gate from an array, and using `DrawRandomInt` as the index fails because it doesn't support controlled and thus adjoint cannot be generated.
**To Reproduce**
```qsharp
operation Test3() : Bool {
let ind = DrawRandomInt(0, 2);
let op = [Rx, Ry, Rz][ind](1., _);
let op1 = [Rx, Ry, Rz][DrawRandomInt(0, 2)](1., _);
true
}
```
`op` and `op1` are initialized in the same way (except the variable `ind`), but the second one yields an error.
**Expected behavior**
Two initializations of `op` and `op1` should behave the same, since they do the same thing.
**Screenshots**

**System information**
- VS Code 1.93.0
- QDK 1.8.0
Contributor guide
Research direction
Start by running the Q# reproduction in the issue and compare the `op` and `op1` initializations. Trace how controlled and adjoint variants are generated for operations selected through arrays, especially when the index expression is an inline `DrawRandomInt` call. Done means both equivalent initializations compile and behave consistently without requesting unsupported variants.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100