Skip to content

Commit 7fdda87

Browse files
committed
Fix go/impossible-interface-nil-check for separate post-update nodes
When tracing back from nil checks on interfaces, ignore post-update nodes. There will always be a corresponding pre-update node that contains the information we want.
1 parent 2629369 commit 7fdda87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

go/ql/src/RedundantCode/ImpossibleInterfaceNilCheck.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ predicate flowsToInterfaceNilCheck(DataFlow::Node nd) {
3535
*/
3636
predicate nonNilWrapper(DataFlow::Node nd) {
3737
flowsToInterfaceNilCheck(nd) and
38-
forex(DataFlow::Node pred | pred = nd.getAPredecessor() |
38+
forex(DataFlow::Node pred |
39+
pred = nd.getAPredecessor() and not pred instanceof DataFlow::PostUpdateNode
40+
|
3941
exists(Type predtp | predtp = pred.getType().getUnderlyingType() |
4042
not predtp instanceof InterfaceType and
4143
not predtp instanceof NilLiteralType and

0 commit comments

Comments
 (0)