This fixes a crash while typing a positional pattern.#26481
This fixes a crash while typing a positional pattern.#26481gafter merged 3 commits intodotnet:features/recursive-patternsfrom
Conversation
| BoundExpression deconstruct = MakeDeconstructInvocationExpression( | ||
| node.SubPatterns.Count, inputPlaceholder, node, diagnostics, outPlaceholders: out ImmutableArray<BoundDeconstructValuePlaceholder> outPlaceholders); | ||
| deconstructMethod = deconstruct.ExpressionSymbol as MethodSymbol; | ||
| if (deconstructMethod == null) |
There was a problem hiding this comment.
deconstructMethod is a MethodSymbol. Use is null or (object). #Resolved
There was a problem hiding this comment.
Below you check outPlaceholders.IsDefaultOrEmpty to see if the deconstruction is an error, while here you check if the method is null. It seems like this code could be simplified significantly by settling on a single check and reusing it, including where we check isError below. #ByDesign
There was a problem hiding this comment.
That is a test for a particular subelement of the deconstruction being an error, not the whole thing. Checking that the method is null is one way the whole thing can be in error.
In reply to: 184870737 [](ancestors = 184870737)
| } | ||
|
|
||
| [Fact] | ||
| public void CrashOnWrongArity() |
There was a problem hiding this comment.
Perhaps rename to WrongArity since the test should not crash. And even without the fix, it sounds like the issue was an assert failure rather than a crash. #Resolved
…et/roslyn into rpatterns-typingcrash
This fixes a crash found while typing in the IDE. It is a tiny bug fix.
Fixes #26467
@jcouv @agocke @cston @dotnet/roslyn-compiler May I please have a couple of reviews?