-
Notifications
You must be signed in to change notification settings - Fork 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
Allow type pattern matching to have multiple expression bind to the same variable #1980
Comments
Now I realize this should not be limited to |
That's where the |
Why is there a need for a new syntax? The above example is just a simple logical expression. |
@HaloFour my understanding is that |
Those "type tests" are just a very limited form of pattern, just like those constant patterns. C# 8.0 will greatly expand on the types of supported patterns, including recursive patterns, and success = other is XXX xxx or YYY { Val: XXX xxx }; Assuming that |
That said, if you're looking for support for this outside of pattern matching, such as with case guards or Boolean expressions, that would be its own proposal. |
Closing as championed in #4018 |
Excerpt from own Roslyn-based code:
Should be able to do:
Basically, in
expr is Type variable
why can'tvariable
be any existing variable of a matching type (e.g. assignable fromType
). I'd even be ok withexpr is Type out variable
, as long as I don't have to do the(... = ... as ...) != null
The text was updated successfully, but these errors were encountered: