Skip to content

docs: update D1 design to reflect pointer-identity implementation#151

Open
yvonnedevlinrh wants to merge 2 commits into
unbound-force:mainfrom
yvonnedevlinrh:fix/docs-p1-design-scope-approach
Open

docs: update D1 design to reflect pointer-identity implementation#151
yvonnedevlinrh wants to merge 2 commits into
unbound-force:mainfrom
yvonnedevlinrh:fix/docs-p1-design-scope-approach

Conversation

@yvonnedevlinrh

Copy link
Copy Markdown
Contributor

Summary

Blocked by: #149 (must merge first - this branch is based on it)

Updates the p1-local-var-false-positives design document (D1 section) to
match the actual implementation. The design described scope-depth counting
(v.Parent().Parent().Parent() == types.Universe) for identifying
signature-level variables, but the implementation correctly pivoted to
types.Object pointer identity via collectSignatureVars after discovering
that Go's type checker inserts a file scope between package and function
scopes, making depth counting unreliable.

Changes

  • Replaced scope-depth code snippet with the implemented pointer-identity
    approach (collectSignatureVars + sigVars[obj])
  • Updated isExternallyObservable signature to include sigVars parameter
  • Corrected the scope hierarchy diagram to include the file scope:
    Universe - Package - File - FuncType - FuncBody
  • Added explanation of why pointer identity is more robust than depth counting

Testing

  • Documentation-only change - no production or test code modified
  • No CI impact

Follow-up to PR #149.

jflowers and others added 2 commits June 17, 2026 15:13
, unbound-force#144, unbound-force#145)

- Add isExternallyObservable helper using types.Object pointer identity
  to distinguish parameters/receivers/named-returns from body-local
  variables
- Gate MapMutation, SliceMutation, ChannelSend, ChannelClose emission
  behind scope check — local variables no longer produce false positives
- Add collectSignatureVars to build signature-level variable set from
  info.Defs
- Thread info *types.Info to detectSendEffects for scope resolution
- Add 6 test fixtures and 6 tests covering local suppression, named
  return detection, and receiver field access
The design document's D1 section showed scope-depth counting
(v.Parent().Parent().Parent() == types.Universe) for identifying
signature-level variables. The implementation correctly pivoted to
types.Object pointer identity via collectSignatureVars after
discovering that Go's type checker inserts a file scope between
package and function scopes, making depth counting unreliable.

Update the design document to match the actual implementation
and document the scope hierarchy correction.

Assisted-by: OpenCode (claude-opus-4-6)
Signed-off-by: Yvonne Devlin <ydevlin@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review 👀

Development

Successfully merging this pull request may close these issues.

3 participants