-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matching nullables with var pattern #30906
Comments
I'm not so sure, the if (Get() is {} (x, y))
{
//code....
} |
A var-pattern with a parenthesized designation cannot possibly match everything. Now, the current behavior comes from deconstruction assignment
First off, this is an invalid pattern, unless x and y are constants - in which case the correct syntax is Also you don't need to do if (Get() is (var x, var y)) This check for null (if needed) and deconstruct into variables. I believe the same behavior is expected with the shorthand form |
This is definitely a bug. It should simply work. |
It should work for pattern-matching. It should not work with deconstruction. |
I think |
Yes, |
* Permit 0-element and 1-element tuple patterns Fixes dotnet#30962 Replaces dotnet#31027 * Handle null and nullable input for a var pattern with a tuple designation Fixes dotnet#30906 Replaces dotnet#30935 * Don't report missing Deconstruct when there is more than one applicable Deconstruct Fixes dotnet#31031
…31056) * Permit the use of ITuple when Deconstruct exists but is ambiguous. * Permit 0-element and 1-element tuple patterns Fixes #30962 Replaces #31027 * Handle null and nullable input for a var pattern with a tuple designation Fixes #30906 Replaces #30935 * Don't report missing Deconstruct when there is more than one applicable Deconstruct Fixes #31031
Fixed in #31056 |
Version Used: features/recursive-patterns
Steps to Reproduce:
Expected Behavior: Should check for HasValue and deconstruct.
Actual Behavior: Error.
Note: should work for any deconstructible, not just tuples.
Note: in effect, this should be equivalent to the
(var x, var y)
pattern.The text was updated successfully, but these errors were encountered: