fix: add scope-aware filtering to P1 effect detection (#121, #144, #145)#149
Merged
trevor-vaughan merged 1 commit intoJun 18, 2026
Conversation
, 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
e2ac1ee to
c834ddd
Compare
yvonnedevlinrh
approved these changes
Jun 18, 2026
Contributor
There was a problem hiding this comment.
LGTM
Only minor findings in relation to scope and design doc divergence. Updating the design doc can be handled in a separate PR #151
This was referenced Jun 18, 2026
trevor-vaughan
approved these changes
Jun 18, 2026
This was referenced Jun 19, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Eliminates false positive P1 side effects on locally-created maps, slices,
and channels. The root cause:
detectAssignEffects,detectSendEffects,and
detectP1CallEffectschecked type (is this a map/slice/channel?) butnot scope (is this variable externally observable?).
Changes
isExternallyObservablehelper usingtypes.Objectpointeridentity to distinguish parameters/receivers/named-returns from
body-local variables. Uses
collectSignatureVarsto build thesignature-level variable set via
info.Defs.emission behind the scope check.
info *types.InfotodetectSendEffectsfor scope resolution.LocalChannelClose, NamedReturnMapWrite, WriteToStructMap) and 6
corresponding tests with full assertion depth (effect count, type,
tier, description).
Known limitations
Testing
go test -race -count=1 -short ./...Closes #121, #144, #145