-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for making rich check effect handling unbiased for return stateme…
…nt ordering (#254) This PR fixes the bug which made rich check effect handling sensitive to return statement ordering, resulting in false positives for certain cases. The effect of ordering of statements is illustrated in the example below. ``` // Problematic func retPtrErr() (*int, error) { if cond { return new(int), retNil() } return nil, retErr() } // Works fine func retPtrErr() (*int, error) { if cond { return nil, retErr() } return new(int), retNil() } ``` The problem is with no entry being created in `inferredMap` for non-nil error return from `retErr()` in `StoreImplication`, since we don't propagate non-nilness forward. This creates a problem when the anonymous function parameter in `FilterTriggersForErrorReturn` analyzes for nilability of return sites, where it incorrectly assumes that absence in `inferredMap` implies unknown nilability. This PR corrects that logic.
- Loading branch information
1 parent
9012b93
commit 4f33d8c
Showing
2 changed files
with
30 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters