Wasm stack overflow during QIR generation
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
**Describe the bug**
```qsharp
// Recursive wrapper: lets a value be applied to itself.
struct SelfApp {
Run : SelfApp -> (Int -> Int)
}
// Fixed-point (Y / Z) combinator.
function Fix(f : (Int -> Int) -> (Int -> Int)) : Int -> Int {
let g = new SelfApp {
Run = x -> f(v -> (x.Run(x))(v)) // eta-expanded for strict eval
};
g.Run(g)
}
@EntryPoint()
function Main() : Unit {
// Factorial with no named recursion — recursion comes entirely from Fix.
let factorial = Fix(rec -> (n -> n <= 1 ? 1 | n * rec(n - 1)));
for n in 0..6 {
Message($"{n}! = {factorial(n)}");
}
}
```
```
[error] QIR generation failed. Compiling to QIR failed.
RangeError: Maximum call stack size exceeded
```
**To Reproduce**
Generate QIR from VS Code command palette.
**Screenshots**
**System information**
1.29.7-dev
Contributor guide
Assessment
This issue has not been assessed yet.