You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following rule from dotnet/csharplang#2850 needs to be implemented (on the features/patterns3 branch):
Flowing type information from the left to the right of and
It has been suggested that when you write an and combinator, type information learned on the left about the top-level type could flow to the right. For example
boolisSmallByte(objecto)=> o isbyte and <100;
Here, the input type to the second pattern is narrowed by the type narrowing requirements of left of the and. We would define type narrowing semantics for all patterns as follows. The narrowed type of a pattern P is defined as follows:
If P is a type pattern, the narrowed type is the type of the type pattern's type.
If P is a declaration pattern, the narrowed type is the type of the declaration pattern's type.
If P is a recursive pattern that gives an explicit type, the narrowed type is that type.
If P is a constant pattern where the constant is not the null constant and where the expression has no constant expression conversion to the input type, the narrowed type is the type of the constant.
If P is a relational pattern where the constant expression has no constant expression conversion to the input type, the narrowed type is the type of the constant.
If P is an or pattern, the narrowed type is the common type of the narrowed type of the left pattern and the narrowed type of the right pattern if such a common type exists.
If P is an and pattern, the narrowed type is the narrowed type of the right pattern. Moreover, the narrowed type of the left pattern is the input type of the right pattern.
Otherwise the narrowed type of P is P's input type.
The text was updated successfully, but these errors were encountered:
The following rule from dotnet/csharplang#2850 needs to be implemented (on the
features/patterns3
branch):Flowing type information from the left to the right of
and
It has been suggested that when you write an
and
combinator, type information learned on the left about the top-level type could flow to the right. For exampleHere, the input type to the second pattern is narrowed by the type narrowing requirements of left of the
and
. We would define type narrowing semantics for all patterns as follows. The narrowed type of a patternP
is defined as follows:P
is a type pattern, the narrowed type is the type of the type pattern's type.P
is a declaration pattern, the narrowed type is the type of the declaration pattern's type.P
is a recursive pattern that gives an explicit type, the narrowed type is that type.P
is a constant pattern where the constant is not the null constant and where the expression has no constant expression conversion to the input type, the narrowed type is the type of the constant.P
is a relational pattern where the constant expression has no constant expression conversion to the input type, the narrowed type is the type of the constant.P
is anor
pattern, the narrowed type is the common type of the narrowed type of the left pattern and the narrowed type of the right pattern if such a common type exists.P
is anand
pattern, the narrowed type is the narrowed type of the right pattern. Moreover, the narrowed type of the left pattern is the input type of the right pattern.P
isP
's input type.The text was updated successfully, but these errors were encountered: