Skip to content

Model implicit pointer-to-array dereferences as nil consumers#423

Open
TvdW wants to merge 1 commit into
uber-go:mainfrom
TvdW:pointer-to-array
Open

Model implicit pointer-to-array dereferences as nil consumers#423
TvdW wants to merge 1 commit into
uber-go:mainfrom
TvdW:pointer-to-array

Conversation

@TvdW

@TvdW TvdW commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Slicing, indexing, and 2-variable ranging over a *[N]T implicitly dereference the pointer (e.g. p[low:high] is shorthand for (*p)[low:high]), so they panic on a nil pointer. Notably this holds even for slice forms like p[:0] and p[:] that are safe on a nil slice. len/cap and range loops with at most one (possibly blank) iteration variable never read the elements and stay nil-safe.

Add PtrLoad consumers for these cases in consumeIndexExpr, the SliceExpr case of AddComputation (bypassing the slice-only safe-slicing carve-out), and case 2 of backpropAcrossRange.

Claude-assisted, human-reviewed.

Slicing, indexing, and 2-variable ranging over a *[N]T implicitly
dereference the pointer (e.g. p[low:high] is shorthand for
(*p)[low:high]), so they panic on a nil pointer. Notably this holds
even for slice forms like p[:0] and p[:] that are safe on a nil
slice. len/cap and range loops with at most one (possibly blank)
iteration variable never read the elements and stay nil-safe.

Add PtrLoad consumers for these cases in consumeIndexExpr, the
SliceExpr case of AddComputation (bypassing the slice-only safe-slicing
carve-out), and case 2 of backpropAcrossRange.
@TvdW TvdW force-pushed the pointer-to-array branch from 2ccab67 to 19bc060 Compare June 17, 2026 19:20
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.29%. Comparing base (d3e528f) to head (19bc060).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #423      +/-   ##
==========================================
+ Coverage   87.26%   87.29%   +0.02%     
==========================================
  Files          74       74              
  Lines        8444     8463      +19     
==========================================
+ Hits         7369     7388      +19     
  Misses        876      876              
  Partials      199      199              

☔ 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.

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.

1 participant