Closed
Description
The following program is valid go.
package main
import (
"fmt"
)
func main() {
err := fmt.Errorf("%v %#[1]v", struct{ string }{})
fmt.Println(err)
}
https://play.golang.com/p/Ymc7t3H_bFR
However it causes go-errorlint to panic due to the indexing operator in the formatting verb.
$ go-errorlint -errorf .
panic: runtime error: index out of range [1] with length 1
goroutine 6 [running]:
github.com/polyfloyd/go-errorlint/errorlint.verbOrder(...)
.../src/github.com/polyfloyd/go-errorlint/errorlint/printf.go:17
github.com/polyfloyd/go-errorlint/errorlint.printfFormatStringVerbs({0xc0000108d0, 0xc0000109f0, 0xc000010900, 0xc000010930, 0xc000010960, 0xc0000109c0, 0xc000010990, {0x0, 0x0, 0x0}}, ...)
.../src/github.com/polyfloyd/go-errorlint/errorlint/lint.go:106 +0x3c5
github.com/polyfloyd/go-errorlint/errorlint.LintFmtErrorfCalls(0x0?, {0xc0000108d0, 0xc0000109f0, 0xc000010900, 0xc000010930, 0xc000010960, 0xc0000109c0, 0xc000010990, {0x0, 0x0, ...}})
.../src/github.com/polyfloyd/go-errorlint/errorlint/lint.go:39 +0x1d8
github.com/polyfloyd/go-errorlint/errorlint.run(0xc00007f520)
.../src/github.com/polyfloyd/go-errorlint/errorlint/analysis.go:46 +0x2b8
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc00047a140)
.../pkg/mod/golang.org/x/tools@v0.1.12/go/analysis/internal/checker/checker.go:731 +0x9fe
sync.(*Once).doSlow(0x1263089?, 0xc0001681c0?)
...root/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
...root/src/sync/once.go:59
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0xc00000c870?)
.../pkg/mod/golang.org/x/tools@v0.1.12/go/analysis/internal/checker/checker.go:619 +0x3d
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0x0?)
.../pkg/mod/golang.org/x/tools@v0.1.12/go/analysis/internal/checker/checker.go:607 +0x25
created by golang.org/x/tools/go/analysis/internal/checker.execAll
.../pkg/mod/golang.org/x/tools@v0.1.12/go/analysis/internal/checker/checker.go:613 +0x165
This happens with v1.0.0 and main at 2f09b52, only with go1.18, go1.17 does not fail.