Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: incorrect printf "invalid argument index" with ... argument #34007

Open
cherrymui opened this issue Sep 1, 2019 · 2 comments
Open
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@cherrymui
Copy link
Member

What version of Go are you using (go version)?

tip (79669dc)

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

darwin/amd64

What did you do?

https://play.golang.org/p/uIeIGQWBhgB

package main

import (
	"fmt"
)

func main() {
	s := []interface{}{"Hello", "playground"}
	fmt.Printf("%[2]s\n", s...)
}

What did you expect to see?

No vet warning.

I think this is a valid program, which prints "playground" as intended. It doesn't seem like a potential bug to me.

What did you see instead?

./prog.go:9:2: Printf format has invalid argument index [2]
@mvdan mvdan added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Sep 1, 2019
@mvdan mvdan added this to the Unplanned milestone Sep 1, 2019
@Matts966
Copy link

Matts966 commented Sep 2, 2019

I sent a patch to fix this problem.
https://go-review.googlesource.com/c/tools/+/192857

@gopherbot
Copy link

Change https://golang.org/cl/192857 mentions this issue: analysis/passes/printf: emit linter message related to the index of arguments only when the number of arguments is precise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants