Skip to content

Add hook points for error-returning functions that make arguments nonnil#426

Merged
yuxincs merged 6 commits into
mainfrom
yuxincs/add-handling-for-json-marshal
Jun 17, 2026
Merged

Add hook points for error-returning functions that make arguments nonnil#426
yuxincs merged 6 commits into
mainfrom
yuxincs/add-handling-for-json-marshal

Conversation

@yuxincs

@yuxincs yuxincs commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This pull request introduces support for recognizing and modeling the effect of trusted functions whose error return, when nil, guarantees that a specific pointer argument is non-nil. The primary example handled is json.Unmarshal(data, &v), where a successful unmarshal ensures that v is non-nil. This is achieved by adding a new analysis hook, integrating it into the assertion effect system, and providing comprehensive tests.

Fixes #342

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.26%. Comparing base (ac4de95) to head (9014ccc).

Files with missing lines Patch % Lines
...ertion/function/assertiontree/rich_check_effect.go 88.88% 2 Missing and 2 partials ⚠️
hook/error_return.go 66.66% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #426      +/-   ##
==========================================
- Coverage   87.29%   87.26%   -0.03%     
==========================================
  Files          73       74       +1     
  Lines        8396     8444      +48     
==========================================
+ Hits         7329     7369      +40     
- Misses        872      876       +4     
- Partials      195      199       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

Golden Test

Note

✅ NilAway errors reported on standard libraries are identical.

2187 errors on base branch (main, ac4de95)
2187 errors on test branch (1b163db)

@yuxincs yuxincs enabled auto-merge (squash) June 17, 2026 16:11
yuxincs and others added 3 commits June 17, 2026 09:25
@yuxincs yuxincs merged commit d3e528f into main Jun 17, 2026
9 checks passed
@yuxincs yuxincs deleted the yuxincs/add-handling-for-json-marshal branch June 17, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Common pattern for json.Unmarshall with nil map flagged as false positive

2 participants