-
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
Pattern Matching #4882
Merged
Merged
Pattern Matching #4882
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Support for `Expression is Type Identifier` as the first pattern-matching operator Including implementation of scoping for match-variables
1. Do not parse as a declaration pattern when an identifier might be a contextual identifier with its usual meaning. This occurs in query expressions. 2. Implement flow analysis for declaration patterns: any pattern variables are *definitely assigned when true* for the enclosing `is` pattern matching expression 3. Implement lowering 4. Punch through; one test case works end-to-end.
dangling local declarations in a speculative semantic model, marking them [Fact(Skip = "#206")]
/cc @semihokur |
<Field Name="IsVar" Type="bool"/> | ||
</Node> | ||
|
||
<Node Name="BoundIsPattern" Base="BoundExpression"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be called BoundIsPatternExpression
…into features/patterns
Fix a bug in value pattern lowering.
if (o is Point { X is int x, Y is int y }) ...
It looks like recent changes made highlight refs functional on pattern matching variables. Locking in the victory. closes #9110
Test highlight refs on simple pattern match
Test scope of pattern variables declared within an 'if' statement.
Do not allow a local function declaration as an embedded statement. Handle deep expressions better in the pattern variable finder.
Do not allow a let-statement as an embedded statement.
…tching Reverse engineered positional matching
Test/fix scoping of pattern variables in an expression-bodied lambdas and query expressions.
This addresses #9104 in the following ways: - Fixes the gaps in data flow analysis that were causing the original assert in the bug. - Disables extract method on pattern matching for now. Filed #9244 to design scenarios here. In order to fill in the data flow gaps I used commit 9d36a64 as a guide. This change removed declaration expressions from the code base and hence gave a good outline of where data flow would be affected by pattern declaration expressions. closes #9104
Implement SymbolInfo for the property name of a property pattern
Disable extract method on pattern matching features
Test/fix scoping of pattern variables in expression-bodied functions and properties.
Pattern format and indentation work
Add a test for an ambiguous property reference in pattern matching.
Merge future to features/patterns
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An implementation of pattern matching as specified in #206. You can follow the progress here. Much of this work will be pulling pieces of the implementation from https://github.com/semihokur/pattern-matching-csharp
Related features possibly to be added at the same time as pattern-matching:
Progress checklist:
SemanticModel.GetDeclaredSymbol
for pattern variable declarations.expression is Type Identifier
in most statements.TestResource.AllInOneCSharpCode
to handle all pattern forms.SemanticModel
.var
IDType ( Pattern ... )This will be done when Records are integrated.Allow declaration ofThis will be done when Records are integrated.operator is
match
?)switch
does in corresponding situations.Records will be added in a separate feature branch.