meetings/2024/LDM-2024-11-04.md
not and or patternsIssue: https://github.com/dotnet/roslyn/issues/75506
Document: LDM-2024-11-04-patterns.md
Today, we took a look at an issue with precedence in not patterns, when combined with or patterns. This is an area where unfortunate Englishisms get in the way of understanding
syntax; when a native English-speaking person says "x is not 1 or 2", they usually mean that x is not 1, and it's also not 2. However, C# uses the same precedence as
the standard unary operators for the pattern operators, so the same thing written in a pattern actually means x is (not 1) or 2. Our initial hope was that this would not be a
major issue. However, we now have good evidence that it is; in internal scans, the error rate was nearly 90%. While we certainly can't go change the precedence from the past, we
think that we can detect this and introduce a warning for the scenario. We will issue a warning when a not pattern causes a subsequent or pattern to be subsumed; while we
wouldn't mind extending subsumption to an entire pattern, not just for this specific scenario, we think that will be significantly more complicated, and we don't want to delay
fixing this.
We will add a warning for when a not pattern causes a subsequent or pattern to be subsumed.
The outcome of this session was a restructure of how we approach record-keeping on csharplang. The results were documented in the process changes in this PR, with the goal to improve the visibility of issue status on the repo.