Closed yuxincs closed 1 month ago
Attention: Patch coverage is 87.50000%
with 6 lines
in your changes missing coverage. Please review.
Project coverage is 87.66%. Comparing base (
3c8ea06
) to head (fca4e01
). Report is 1 commits behind head on main.
Files with missing lines | Patch % | Lines |
---|---|---|
hook/replace_conditional.go | 66.66% | 3 Missing and 3 partials :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
[!WARNING]
❌ NilAway errors reported on stdlib are different 📉.3271 errors on base branch (main, 3c8ea06) 3263 errors on test branch (934834a)
This PR introduces a new hook point in the CFG preprocessing logic to replace conditionals with equivalent expressions (along with a few simple renames and comment additions for better readability).
With the new hook, we are introducing modeling for
errors.As(err, &target)
since it is equivalent toerrors.As(err, &target) && target != nil
. This makes the implication explicit such that NilAway is able to understand it during the analysis.Note that technically
target
can still be nil even iferrors.As(err, &target)
is true. For example, if err is a typed nil (e.g.,var err *exec.ExitError
), thenerrors.As
would actually find a match, buttarget
would be set to the typed nil value, resulting in anil
target. However, in practice this should rarely happen such that even the official documentation assumes the target is non-nil after such check [1]. So here we make this assumption as well.[1] https://pkg.go.dev/errors#As
Fixes #95