Break and continue support#3451
Conversation
01bb261 to
5c93ad6
Compare
5c93ad6 to
5af8087
Compare
5af8087 to
6e53058
Compare
|
This is probably supposed to report that break isn't allowed there, rather than that the type couldn't be inferred operation Main() : Unit {
mutable x = 1;
while (true) {
() -> break;
}
x += 1;
} |
|
This reports an RIR timeout operation Main() : Unit {
use q = Qubit();
for p in [q] {
for p in [q] {
for p in [q] {
for p in [q] {
for p in [q] {
for p in [q] {
break
}
}
}
}
}
}
} |
| "patterns": [ | ||
| { | ||
| "name": "keyword.control.qsharp", | ||
| "match": "\\b(use|borrow|mutable|let|set|if|elif|else|repeat|until|fixup|for|in|while|return|fail|within|apply)\\b" |
There was a problem hiding this comment.
Would you expect the local playground to pick this up? I'm not seeing it.
|
I'm seeing an LS panic (and a possibly downstream RIR generation failure) for @EntryPoint(Adaptive)
operation Main() : Result {
use qq = Qubit[2];
repeat {
H(qq[0]);
Controlled X([qq[break]], qq[1]);
} until (M(qq[1]) == One)
fixup {
ResetAll(qq);
}
let r = M(qq[0]);
ResetAll(qq);
r
}Related: with Interestingly, |
|
LS panic for @EntryPoint(Adaptive)
operation Main() : Result {
use qq = Qubit[2];
repeat {
H(qq[0]);
use rr = Qubit[break];
Controlled X(break );
} until (M(qq[1]) == One)
fixup {
ResetAll(qq);
}
let r = M(qq[0]);
ResetAll(qq);
r
}I was about to type a comma after the |
|
I don't think this needs to work, but it stands out from a bunch of other nonsensical code that does work @EntryPoint(Adaptive)
operation Main() : Result {
use qq = Qubit[2];
repeat {
H(qq[break]);
Controlled X(continue, qq[1]);
} until (M(qq[1]) == One)
fixup {
ResetAll(qq);
}
let r = M(qq[0]);
ResetAll(qq);
r
}In particular, the same example emits QIR with |
…oops containing an unconditional failure as code that never returns a value.
Closes #1835