-
Notifications
You must be signed in to change notification settings - Fork 354
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
Returning an Optional.empty() inside try-with-resources causes mutant to survive #968
Comments
Hi @nikosstais, thanks for the report (and sorry for the slow response). I've taken a look at this, and it is going to be an awkward issue to resolve. The filtering of Unfortunately, try-with-resources is causing the compiler to store the ref in a local variable before returning. Filtering this out at the bytecode level would require an analysis that tracked what was stored, but didn't trigger for more complex code where the mutant shouldn't be filtered. It's certainly possible, but not something that is going to be fixed quickly. |
Ok, couldn't help picking at this. There should be something in the next release which picks up at leasst some cases of this. |
A partial fix has been merged. It works if the compiler chooses to order the instructions so the |
Release 1.9.4 extends the analysis to work with java 8 and catch more complex cases. |
I have a mutant that cannot be killed with message:
replaced return value with Optional.empty for com/blah::createFile → SURVIVED
I am using version 1.7.3
Based on quick start guide https://pitest.org/quickstart/mutators/ :
Pitest will filter out equivalent mutations to methods that are already hard coded to return the empty value.
It seems that above statement is not respected in my case
The text was updated successfully, but these errors were encountered: