-
Notifications
You must be signed in to change notification settings - Fork 155
fix for null analysis issue for conditional expressions #4028
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
base: master
Are you sure you want to change the base?
Conversation
@stephan-herrmann - can you please review when you get time? TIA. |
At a very brief look from a distance I was a bit surprised about the size of the change, but maybe all this is needed, so... Two things you might want to check:
|
Thanks @stephan-herrmann for the input. The following gives an erroneous message - investigating the same:
|
This doesn't flag the "definitely null" for the conditional inside a loop yet
` |
@stephan-herrmann - This particular case is corrected .However, the code here doesn't flag a null error in the conditional expression. Looking through the LoopingFlowContext.checkOnDeferredNullChecks(), I see that each variable is checked for nullity and at that point the null error is flagged in the case of if statement. Investigating whether its pragmatic (it is possible for sure) to propagate this nullity property upwards to the parent as appropriate (in situations similar to that of conditional expression involving variables). |
What it does
fixes #3990
Null in Conditional Expressions are now reported with this fix.
General algorithm:
At EqualExpression, check for conditional expression in checkNullComparison and then the logic followed is similar to the flow analysis of checkVariableComparison. Additional error code of 990 error code [IProblem.RedundantNullCheckNullValueExpression] is introduced - see below as well.
A few points:
How to test
Test cases are part of the PR
Author checklist