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
Use .equals() for nodeValues if == does not work; fixes #3484 #3523
Conversation
…o nodevalues-eq-then-equals
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would break one of the basic assumptions of the CFG, quoting from https://github.com/typetools/checker-framework/blob/master/dataflow/src/main/java/org/checkerframework/dataflow/cfg/node/Node.java#L29:
"Note that two {@code Node}s can be {@code .equals} but represent different CFG nodes. Take care to use reference equality, maps that handle identity {@code IdentityHashMap}, and sets like {@code IdentityMostlySingleton}."
So even though it might fix this issue, it would introduce a lot of problems about our CFG representation.
I'll look at your email with alternative suggestions and we can discuss this in more detail in our next meeting.
This PR does not violate the assumption, because it does not add any new items to the map, nor does it create non-identity maps or sets. |
https://github.com/typetools/checker-framework/pull/3523/files#diff-d4108228a0a5407e00c090c2e97d8b6dR178 uses If that node should have a value, we should figure out why there is no result for it, instead of returning a possibly incorrect result. |
…alysisresult-repr
…alysisresult-repr
The assumption you quoted is about the class's representation. An accessor (which is the only thing being changed here) cannot violate representation invariants. This pull request is not the best way to solve the problem in the long run, but it fixes multiple problems without introducing any new ones. It seems appropriate to merge this change, and open an issue to fix the CFG construction algorithm. |
I really don't see what you are trying to argue. You are not using the datastructure correctly and incorrectly use I also don't see how this fixes the issue in any real setting where there is more than one use of the variable. Take this example, based on the "fixed" test case from the PR: class Demo3523 {
void unreachableCatch(String[] xs) {
String t = "";
t.toString();
t.hashCode();
try {
} catch (Throwable e) {
// :: error: (dereference.of.nullable)
t.toString();
}
}
} Running the Nullness Checker on that still gives the unexpected
because So if you insist on committing this incorrect code, at least add a big disclaimer to the method that these changes should be undone and file a follow-up issue to actually fix the problem. |
I agree entirely that this needs a big comment warning that it is not the right fix and should be undone when CFG construction is fixed. I was waiting for #3522 to be merged to write that comment, because once that is merged I can open an issue about CFG construction, and refer to the issue in the comment. |
…o nodevalues-eq-then-equals
…o nodevalues-eq-then-equals
…o nodevalues-eq-then-equals
…-method into nodevalues-eq-then-equals
…o nodevalues-eq-then-equals
…-method into nodevalues-eq-then-equals
Merge after #3522