-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
typeThe HM(X) type system, excluding the trait partThe HM(X) type system, excluding the trait part
Description
Currently loops are typed as (), which is incorrect. For example, even with no break-returning value statement, a loop should have type never if there is no break, or () if there is at least one break in it. Later, when break can return values, then the type of that value should be used.
One clean way to do that is to add loop information in the typing context, using a LoopFrame:
struct LoopFrame {
result_ty: TypeVar, // the α for this loop
saw_break: bool, // whether any break occurred
label: Option<Name>, // if labeled breaks are supported
}
This would also allow nicely the detection of breaks outside loops.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
typeThe HM(X) type system, excluding the trait partThe HM(X) type system, excluding the trait part