Skip to content
Open
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8d0ac60
Initial break and continue support
idavis Jul 10, 2026
a20ff3e
Add early fixed-point detection for loop condition, body, and local c…
idavis Jul 13, 2026
722ed03
break and continue are now distinguished from function-level divergence
idavis Jul 14, 2026
5163a45
Prevent the language service from crashing by correctly recognizing l…
idavis Jul 14, 2026
c5c7358
Update error codes
idavis Jul 20, 2026
6f6e93c
keep break and continue from causing unexpected side effects
idavis Jul 20, 2026
b3eeea6
Feedback updates
idavis Jul 20, 2026
c957119
fixing historical framing of tests
idavis Jul 20, 2026
1482145
Prove there is one matching return in test for better accuracy.
idavis Jul 20, 2026
758edb8
Fixing user reported issues
idavis Jul 20, 2026
94dcc5d
Updating snapshot from bug fix
idavis Jul 20, 2026
3d01b83
Lint
idavis Jul 20, 2026
765f2b9
nested loop controls and divergence are now handled correctly and cov…
idavis Jul 21, 2026
35b22f5
now scans assignment places in evaluation order, including indexed-as…
idavis Jul 21, 2026
8ad3226
check loop exits based on code that can actually run, handle breaks i…
idavis Jul 21, 2026
61dfc42
recognize returns in nonempty range loops
idavis Jul 21, 2026
44a96a4
Update passcontext call with new sig
idavis Jul 21, 2026
58cef21
Clean up some tests
idavis Jul 21, 2026
050c8c3
Updating tests
idavis Jul 21, 2026
7ccb0f0
ssertion now distinguishes the skipped middle iteration from any two …
idavis Jul 21, 2026
5e1ef2d
test now records the visited prefix as 12, rather than the ambiguous …
idavis Jul 21, 2026
695fab0
Handle divergence with known bool values
idavis Jul 21, 2026
5ffe2e7
cover break/continue divergence in operand positions
idavis Jul 21, 2026
24c6008
split the checks into two focused visitors matching the existing conv…
idavis Jul 22, 2026
7d66ff5
Cleaning up comments
idavis Jul 22, 2026
0bc508e
Cleaning up mid-impl docs
idavis Jul 22, 2026
d70acf0
simplify how the compiler scans for break and continue in loops
idavis Jul 22, 2026
254cdc4
fixup tests
swernli Jul 24, 2026
7364fc9
Clean up extra params
idavis Jul 24, 2026
040a620
Perf opt and localization of enum
idavis Jul 24, 2026
9d3fb23
Add trailing stmts to tests
idavis Jul 24, 2026
4bf3dcf
Update HIR/FIR Q# codegen range format
idavis Jul 24, 2026
e42508e
multi-break, multi-cont sample tests
idavis Jul 24, 2026
bb593d9
Force parens when rendering upop and binop from HIR/FIR to cleary dem…
idavis Jul 24, 2026
a561c93
Refactor common code
idavis Jul 24, 2026
4c83cf2
Only wrap nested binop/unop in parens
idavis Jul 24, 2026
40fd666
Extend expr operand lifting
idavis Jul 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions samples/language/BreakAndContinue.qs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// # Sample
// Break and Continue
//
// # Description
// The `break` statement immediately exits the innermost enclosing loop.
// The `continue` statement skips the rest of the current iteration and
// proceeds to the next one. Both can be used in the bodies of `for`,
// `while`, and `repeat`-`until` loops. They cannot be used in loop
// conditions or in `repeat`-`until` fixup blocks.

function Main() : (Int, Int, Int) {
// Use `break` to stop a loop early. Here we find the first integer whose
// square exceeds 50 and then stop searching.
mutable firstOverFifty = 0;
for n in 1..100 {
if n * n > 50 {
firstOverFifty = n;
break;
}
}

// Use `continue` to skip selected iterations. Here we sum the numbers from
// 1 to 20, skipping every multiple of 3.
mutable sumWithoutMultiplesOfThree = 0;
for n in 1..20 {
if n % 3 == 0 {
continue;
}
sumWithoutMultiplesOfThree += n;
}

// `break` and `continue` also work in `while` loops. Here we count how many
// times 1 can be doubled before the result exceeds 1000.
mutable doublings = 0;
mutable value = 1;
while true {
value *= 2;
if value <= 1000 {
doublings += 1;
continue;
}
break;
}

return (firstOverFifty, sumWithoutMultiplesOfThree, doublings);
}
Loading
Loading