Add error for multiple null suppressions#37139
Conversation
| // G(s!!); | ||
| Diagnostic(ErrorCode.ERR_DuplicateNullSuppression, "s").WithLocation(6, 11), | ||
| // (7,12): error CS8715: Duplicate null suppression operator ('!') | ||
| // G((s!)!); |
There was a problem hiding this comment.
(s!)! [](start = 29, length = 5)
Does this need to be an error?
There was a problem hiding this comment.
This is pretty much just reserving the right to consider !! a distinct operator in the future, right? So probably no need to complain in this scenario.
There was a problem hiding this comment.
I expected we would implement this as a parsing error: expr!! would be an error, but (expr!)! and expr! ! would not.
I wouldn't push back very hard on this given the timing though, so up to you.
In reply to: 302638675 [](ancestors = 302638675)
jcouv
left a comment
There was a problem hiding this comment.
LGTM but I would notify Mads/LDM of the implemented behavior, which differs from my expectation.
Thanks (iteration 1)
|
I think this should be a semantic error for now. We can always relax it later. |
* dotnet/master: Fix master build (dotnet#37163) Add error for multiple null suppressions (dotnet#37139) Check for uninitialized non-nullable field-like events (dotnet#37073) EnC emit tests for C# 8.0 patterns (dotnet#37025) Update dependencies from https://github.com/dotnet/arcade build 20190710.8 Update dependencies from https://github.com/dotnet/arcade build 20190709.6 [master] Update dependencies from dotnet/arcade (dotnet#37001) Add annotations to HostWorkspaceServices.cs and HostLanguageServices.cs Add nullable annotations to members in Solution.cs, SolutionInfo.cs, and SolutionState.cs Annotate Contract.cs Add nullable annotations and fixes to Workspace.cs Fix typo in documentation comment for Workspace.Dispose Check in copy of NullableAttributes.cs copied from coreclr Use switch expressions to simplify GetAccessibilityAndModifiers
Fixes #37111