Skip to content

[sergo] linters: verify append/len resolve to the builtin (appendbytestring, lenstringzero) - #77329

Merged
pelikhan merged 1 commit into
mainfrom
sergo/builtin-universe-check-r127-6599dd94c8d15e51
Nov 13, 2026
Merged

pelikhan merged 1 commit into
mainfrom
sergo/builtin-universe-check-r127-6599dd94c8d15e51

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

appendbytestring and lenstringzero identified the builtins append / len by identifier name only. A locally shadowed or user-defined append/len was treated as the builtin, so the linters reported false positives and attached suggested fixes that change semantics or do not compile. appendoneelement and slicemakezerolength already guard against this with a types.Universe.Lookup check; these two did not.

Evidence

  • pkg/linters/appendbytestring/appendbytestring.go:50-51 matched ident.Name != "append" with no object check. With append := func(dst []byte, src ...byte) []byte {...}, append(b, []byte(s)...) was flagged and "fixed" to append(b, s...), which does not compile (string spread is only valid for the builtin).
  • pkg/linters/lenstringzero/lenstringzero.go:221-228 (isLenCall) matched ident.Name == "len" only. With a shadowed len := func(x string) int, len(s) == 0 was rewritten to s == "", changing behavior. The same helper feeds lenStringArg, so the alias path (n := len(s); n == 0) was affected too.
  • A grep for name-only builtin matches (Name (==|!=) "append|len|make|delete|...") across pkg/ showed the other sites already resolve through types.Universe or *types.Builtin.

Changes

  • appendbytestring: add pass.TypesInfo.ObjectOf(ident) != types.Universe.Lookup("append") guard.
  • lenstringzero: isLenCall now takes pass and requires the identifier to resolve to types.Universe.Lookup("len"); the three call sites are updated.
  • New negative fixtures: appendbytestring/testdata/src/appendbytestring/shadowed_append.go, lenstringzero/testdata/src/lenstringzero/shadowed_len.go (direct and alias forms). They contain no // want lines, so they assert no diagnostics.

Validation

  • Serena (gopls) diagnostics on all four changed/added .go files: 0 errors (only pre-existing-style "unused function/parameter" hints on the fixtures).
  • go test and gofmt were NOT run: the sandbox denied go/gofmt Bash commands in this run. analysistest.RunWithSuggestedFixes for both packages should be run in CI. The edits are small and mirror the existing appendoneelement guard, and no existing fixture shadows append/len, so existing expectations should be unchanged.

🤖 Generated with [Claude Code]((claude.com/redacted)

Generated by 🤖 Sergo - Serena Go Expert · claude · routed: sonnet55 high · ~48 AIC · ⌖ ~2 AIC · ⊞ 4.7K · ◷

  • expires on Nov 19, 2026, 7:52 PM UTC-08:00

@github-actions github-actions Bot added cookie Issue Monster Loves Cookies! sergo labels Nov 13, 2026
@pelikhan
pelikhan marked this pull request as ready for review November 13, 2026 04:54
Copilot AI adaptive review requested due to automatic review settings November 13, 2026 04:54
@pelikhan
pelikhan merged commit fc28ffb into main Nov 13, 2026
13 checks passed
@pelikhan
pelikhan deleted the sergo/builtin-universe-check-r127-6599dd94c8d15e51 branch November 13, 2026 04:55
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: haiku55 xhigh · ~1 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 8.6K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: haiku55 xhigh · ~2 AIC · ⌖ ~2 AIC · ◇ ~1 AIC · ⊞ 7.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Specification Reviewer completed successfully!

PR Specification Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Specification Reviewer · gpt56 · ~1 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

Generated by PR Specification Reviewer for #77329

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt61 medium · ~4 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 182 · ◷

Generated by Ponytail Reviewer for #77329

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ PR Code Quality Reviewer completed the code quality review.

PR Code Quality Reviewer

Outcome: reported_action

The agent completed and reported one or more actions. The no-op output is a completion signal, not a claim that no action was taken.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from PR Code Quality Reviewer · gpt56 · ~2 AIC · ⌖ ~1 AIC · ◇ ~1 AIC · ⊞ 1.6K · ◷

🔎 Code quality review by PR Code Quality Reviewer

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change addressing linter false positives caused by shadowed Go builtins.

No open issues 🎉

What changed in this PR

This PR fixes false positives in gh-aw’s appendbytestring and lenstringzero linters by verifying that calls resolve to Go builtins rather than shadowed functions. This prevents suggested fixes that change behavior or fail to compile.

Changes:

  • Add builtin identity checks using types.Universe.Lookup.
  • Apply the len check to direct comparisons and alias tracking.
  • Add negative fixtures for locally shadowed append and len.
File Description
pkg/​linters/​lenstringzero/​testdata/​src/​lenstringzero/​shadowed_len.go Adds negative fixtures for direct and aliased shadowed len calls.
pkg/​linters/​lenstringzero/​lenstringzero.go Requires builtin identity when matching len calls.
pkg/​linters/​appendbytestring/​testdata/​src/​appendbytestring/​shadowed_append.go Adds a negative fixture for shadowed append.
pkg/​linters/​appendbytestring/​appendbytestring.go Skips calls that do not resolve to builtin append.

Review effort: Balanced (dynamic)

@github-actions

Copy link
Copy Markdown
Contributor Author

🎉 This pull request is included in a new release.

Release: v1.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cookie Issue Monster Loves Cookies! sergo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants