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
Is the discard pattern permitted at the top level of a switch statement? If so, it could change the meaning of existing code. I suggest we require you write case var _ to avoid any ambiguity.
Resolution 2018-10-10: A discard pattern in the presence of a constant will bind to the constant only in a switch statement case, with a warning given under a warning wave. Elsewhere in a pattern it is a discard pattern. A discard pattern in an is-expression in the presence of a type will bind to the type, with a warning under a warning wave.
The text was updated successfully, but these errors were encountered:
- A discard pattern is not accepted at the top level in a switch statement. In that case `_` binds to a constant in scope with a warning WRN_CaseConstantNamedUnderscore that is included in a warning wave.
- A discard pattern is not accepted at the top level in an is-expression. In that case `_` binds to a type in scope with a warning WRN_IsTypeNamedUnderscore that is included in a warning wave.
- Elsewhere a pattern `_` is a discard without warning no matter what definition for `_` might be in scope.
Fixesdotnet#30650
See also dotnet#30846
* Discard pattern versus symbol named `_`
- A discard pattern is not accepted at the top level in a switch statement. In that case `_` binds to a constant in scope with a warning WRN_CaseConstantNamedUnderscore that is included in a warning wave.
- A discard pattern is not accepted at the top level in an is-expression. In that case `_` binds to a type in scope with a warning WRN_IsTypeNamedUnderscore that is included in a warning wave.
- Elsewhere a pattern `_` is a discard without warning no matter what definition for `_` might be in scope.
Fixes#30650
See also #30846
From dotnet/csharplang#1054
Is the discard pattern permitted at the top level of a switch statement? If so, it could change the meaning of existing code. I suggest we require you write
case var _
to avoid any ambiguity.Resolution 2018-10-10: A discard pattern in the presence of a constant will bind to the constant only in a switch statement case, with a warning given under a warning wave. Elsewhere in a pattern it is a discard pattern. A discard pattern in an is-expression in the presence of a type will bind to the type, with a warning under a warning wave.
The text was updated successfully, but these errors were encountered: