Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions qs.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import (
"github.com/voedger/voedger/pkg/goutils/logger"
)

type badStruct struct {
ar []int
}

func (bs badStruct) add( i int) {
bs.ar = append(bs.ar, i)

@augmentcode augmentcode Bot Jun 10, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add has a value receiver, so updating bs.ar won’t update the caller’s slice header (the appended element may be lost or only show up via subtle backing-array mutation). Consider making the receiver a pointer (or otherwise returning the updated value) if the intent is to mutate the original badStruct.

Severity: medium

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.

Comment on lines +15 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correctness bug: value receiver makes append invisible to the caller.

add has a value receiver (bs badStruct), so bs is a copy of the caller's struct. append may return a slice with a new length (and potentially a new backing array); assigning it to bs.ar only mutates the local copy. The caller's badStruct.ar is never updated — the method is a silent no-op from the caller's perspective.

Also, add( i int) has a stray space after (, which gofmt will reject (and the repo's formatter check enforces this).

Minimal fix — switch to a pointer receiver and remove the extra space:

Suggested change
func (bs badStruct) add( i int) {
bs.ar = append(bs.ar, i)
func (bs *badStruct) add(i int) {
bs.ar = append(bs.ar, i)

(If the type is removed per the other comment, this one becomes moot.)

}
Comment on lines +11 to +17

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dead code — will fail CI (unused / revive / staticcheck).

badStruct and its method add are not referenced anywhere in the package (this file is the package main entrypoint and only calls cmdproc.ExecRootCmd). The repository's .golangci.yml enables unused, revive, and staticcheck (with all checks), all of which will flag this as U1000/unused-parameter/etc.

If this was added for demonstration/testing purposes, please remove it before merging; otherwise the lint job will block the PR. If it is meant to be used, please add the call site in the same PR so the symbols stop being dead.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

explain more


func main() {
if _, err := cmdproc.ExecRootCmd(context.Background(), os.Args); err != nil {
logger.Verbose(err)
Expand Down
Loading