-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Disallow nullable suppression in patterns #54072
Conversation
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.
LGTM Thanks (iteration 1)
Looks like suppression operator is allowed but only in some cases, presumably only a coincidence because in those other cases parser couldn't handle it, we didn't have an explicit check. How should we approach this?
|
Given that a suppression in such place is nonsense, I think we can just disallow and treat the old behavior as a bug. We'd document the (minor) break just in case. |
I've seen |
Will start email thread with compat council. |
Sorry for the delay. Before I send the email out, let's clarify what is the proposed scope of break. Is it just on number literals and |
All literal expressions can be suppressed right now, wherever they appear in a constant/relational pattern. Only identifiers gave syntax errors previously because we couldn't parse Note this PR doesn't cover the case where a subexpression is suppressed, we may need to descend into the expression more deeply. |
@jcouv This would probably have even less impact than the top-level case but I'm not sure if we want it. I think we could flag the pattern binder and report on any suppression instead of walking down the whole thing again here. |
@alrz I'm not sure where we stand on subexpressions. Could we start with a couple of examples to clarify the discussion? |
Both of these checks are not covered for subexpressions.
|
I think it's fine to leave those last two line as "no error". Let's stick with the PR as scoped :-) |
@dotnet/roslyn-compiler for a second review. Thanks |
1 similar comment
@dotnet/roslyn-compiler for a second review. Thanks |
case SyntaxKind.DefaultLiteralExpression: | ||
diagnostics.Add(ErrorCode.ERR_DefaultPattern, e.Location); | ||
hasErrors = true; | ||
goto default; |
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.
I feel like the particular control flow here is a little weird. i.e. this could be return e
and the continue
s could be break
s. However this seems subjective enough that I won't block the PR about it.
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
CI integration legs won't pass until #55681 is merged. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Fixes #54071