Skip to content
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

fix(mutator): issue where non-nullable fields were swapped by NullCoalescingExpressionMutator #2915

Conversation

ruudschouten
Copy link
Contributor

@ruudschouten ruudschouten commented Apr 15, 2024

Resolves issues with the NullCoalescingExpressionMutator where it tries to create mutations which can never compile, for example;

// request has a nullable EndTime, and a non-nullable StartTime.
node = (request.EndTime ?? request.StartTime)
// The mutator creates three mutators; 
// 1. Swap left and right;  => Only compiles if request.StartTime is Nullable.
(request.StartTime ?? request.EndTime)
// 2. Remove right; => Compiles every time, since this side is always Nullable.
(request.EndTime)
// 3. Remove left  => Only compiles if request.StartTime is Nullable
(request.StartTime)

Mutant 3 resulted in this error being printed in the logs;
Safe Mode! Stryker will try to continue by rolling back all mutations in method. This should not happen, please report this as an issue on github with the previous error message.

I have seen a few issues that reported this, which are;
fix #2682
fix #2384
fix #2801

…ly removes one side if they are both nullable
@rouke-broersma rouke-broersma changed the title fix(nullable_coalescence): issue where non-nullable fields were swapped fix(mutator): issue where non-nullable fields were swapped by NullCoalescingExpressionMutator Apr 26, 2024
@Liam-Rougoor Liam-Rougoor merged commit 2af2947 into stryker-mutator:master May 24, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants