Skip to content
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

Implement constraints on pointer types as input to pattern-matching. #30968

Merged
merged 5 commits into from
Nov 19, 2018

Conversation

gafter
Copy link
Member

@gafter gafter commented Nov 5, 2018

A pointer type can match a var pattern (e.g. var x), a discard pattern (e.g. _), and a constant pattern with the value null (e.g. null). No other pattern forms would permit an input of a pointer type.
Fixes #30798

A pointer type can match a var pattern (e.g. `var x`), a discard pattern (e.g. `_`), and a constant pattern with the value null (e.g. `null`). No other pattern forms would permit an input of a pointer type.
Fixes dotnet#30798
@gafter gafter added this to the 16.0.P2 milestone Nov 5, 2018
@gafter gafter self-assigned this Nov 5, 2018
@gafter gafter requested review from agocke and cston November 5, 2018 23:06
@gafter gafter requested a review from a team as a code owner November 5, 2018 23:06
@gafter gafter added the 4 - In Review A fix for the issue is submitted for review. label Nov 13, 2018
Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -216,7 +216,8 @@ internal BoundExpression ConvertPatternExpression(TypeSymbol inputType, CSharpSy
// input value among many constant tests.
convertedExpression = operand;
}
else if (conversion.ConversionKind == ConversionKind.NoConversion && convertedExpression.Type?.IsErrorType() == true)
else if (conversion.ConversionKind == ConversionKind.NullToPointer ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add some parenthesis here to make order of operations clear.

@gafter gafter merged commit b4b406b into dotnet:features/recursive-patterns Nov 19, 2018
@gafter gafter removed 4 - In Review A fix for the issue is submitted for review. labels Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants