Language service panic for fail in loop
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 212
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 65
Description
**Describe the bug**
```qsharp
@EntryPoint(Adaptive)
operation Main() : Int {
repeat {
fail "hello"
} until 1 < 2
}
```
```
[wasm] Wasm panic occurred: panicked at source/compiler/qsc_fir_transforms/src/invariants.rs:707:5:
Non-Unit block-tail invariant violation: callable 'Main' body Block 0 has type Prim(Int) but trailing Expr 3 has type Tuple([])
```
```
[wasm] Wasm panic occurred: panicked at source/language_service/src/lib.rs:309:44:
RefCell already mutably borrowed
```
**To Reproduce**
[Playground](https://microsoft.github.io/qdk/?code=H4sIAAAAAAAACnNwzSspqgzIz8wr0XBMSSwoySxL1eTKL0gtSizJzM9T8E3MzNPQVLBS8MwrUajmUlBQUChKLUhNhHFAIC0xM0dBKSM1JydfCSxYq1CaV5KZo2CoYKNgxFULADBsJ95kAAAA)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Q# example in the linked Playground, then inspect source/compiler/qsc_fir_transforms/src/invariants.rs around line 707 and source/language_service/src/lib.rs around line 309. Trace how the fail inside the repeat loop produces the invalid block-tail type and the subsequent borrow panic. Done means the example no longer causes either WASM panic and reports or handles the code normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust, wasm
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100