Break and continue support - #3451
Open
idavis wants to merge 36 commits into
Open
Conversation
idavis
force-pushed
the
iadavis/break-cont
branch
from
July 10, 2026 21:08
01bb261 to
5c93ad6
Compare
idavis
force-pushed
the
iadavis/break-cont
branch
2 times, most recently
from
July 13, 2026 18:22
5af8087 to
6e53058
Compare
idavis
marked this pull request as ready for review
July 13, 2026 18:40
Member
|
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;
} |
Member
|
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
}
}
}
}
}
}
} |
amcasey
reviewed
Jul 13, 2026
Member
|
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, |
Member
|
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 |
Member
|
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 |
idavis
force-pushed
the
iadavis/break-cont
branch
from
July 20, 2026 16:41
a4ec90d to
669df98
Compare
…signment controls
…n delayed function calls and skipped conditions, and catch missing return values when loops may run zero times
swernli
force-pushed
the
iadavis/break-cont
branch
from
July 24, 2026 04:23
63a0900 to
254cdc4
Compare
…onstrated precedence
| self.write(op_str); | ||
| self.emit_expr(expr); | ||
| } else { | ||
| self.write("("); |
Contributor
There was a problem hiding this comment.
I don't think you need to wrap unary operations in parens like this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1835