-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
Allow break <expr> so loop expressions can return a value.
Motivation
Supports expression-oriented style while preserving explicit early-exit behavior.
Proposed Semantics
- Loop expression type is nullable/optional
T? break valueyieldsT- Exhausting loop without value break yields
null
Example
let first_even = for n in nums {
if n % 2 == 0 { break n; }
}
// first_even: Int?
Scope
- Parser support for
breakwith optional value - Type checker support for loop result typing (
T?) and break value consistency - Runtime support for carrying break values out of loop execution
Out of Scope
for...else- Non-loop break targets
Acceptance Criteria
- Loop with
break ntype-checks asT? - Loop without value break evaluates to
null - Type error when break values in same loop are inconsistent
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels