test(codemod): pin direct-assignment accumulator pattern for AssertDiffSetsNeedsReplaceForForceNew#564
Merged
intel352 merged 3 commits intoMay 6, 2026
Conversation
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
…ffSetsNeedsReplaceForForceNew Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/e6d4a1f2-66be-48b7-8e17-964af164c028 Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Tighten analyzer to recognize local accumulator pattern for NeedsReplace
test(codemod): pin direct-assignment accumulator pattern for AssertDiffSetsNeedsReplaceForForceNew
May 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a regression test to the iac-codemod analyzer test suite to prevent AssertDiffSetsNeedsReplaceForForceNew from reintroducing a known false-positive when NeedsReplace is assigned from a local accumulator variable via a direct selector assignment (r.NeedsReplace = needsReplace).
Changes:
- Introduces
TestAssertDiffSetsNeedsReplaceForForceNew_DirectAccumulatorAssignIsCleanto pin the “direct-assignment accumulator” pattern as clean (no diagnostics). - Adds a dedicated source fixture (
diffDirectAccumulatorSrc) representing the accumulator + post-loop selector assignment shape.
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.
AssertDiffSetsNeedsReplaceForForceNewwas producing false-positives when a driver used the local-accumulator pattern with a direct selector assignment (r.NeedsReplace = needsReplace) rather than assigningtrueinline. The struct-literal variant (&DiffResult{NeedsReplace: needsReplace}) was already fixed in b0813a2 by adding*ast.KeyValueExprhandling tobodyAssignsField.Changes
TestAssertDiffSetsNeedsReplaceForForceNew_DirectAccumulatorAssignIsClean— explicitly pins the direct-assignment accumulator form described in the issue:This form is handled by the existing
*ast.AssignStmtbranch inbodyAssignsFieldbut had no dedicated test. Adding it prevents a future refactor from silently regressing either accumulator variant without a failing test.