Fix F# pattern matching codegen regression #25615
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
A very common feature of F# - pattern matching - has a extremely bad regression in 6.0.300. This regression results in a pattern silently runs the wrong code branch at runtime.
PR
Issue
Customer Impact
The effect on users is that applications will behave incorrectly at runtime - incorrect logic is executed. This will be particularly difficult for users because the resulting behavior is unusual - a derived class may match a base class. We expect this to impact a significant number of users and it has already been reported independently by two different users.
We build the compiler with an earlier version of the compiler so the current shipping compiler is not affected by this regression.
One way this problem may occur is:
Regression
Yes. Introduced in 6.0.300.
Testing
The error was in the optimizer.
234 new tests were added to cover this scenario and many adjacent scenarios in pattern matching. Tests now cover:
Risk
The risk of taking this fix is isolated to F#. Within that context of F#, the fix is straightforward and limited to the pattern matching optimizer and a single kind of pattern. As such, the risk to F# is small.