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

errorlint fails to correctly parse indexed verbs with modifiers #26

Closed
efd6 opened this issue Aug 11, 2022 · 1 comment
Closed

errorlint fails to correctly parse indexed verbs with modifiers #26

efd6 opened this issue Aug 11, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@efd6
Copy link

efd6 commented Aug 11, 2022

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.

@polyfloyd polyfloyd added the bug Something isn't working label Aug 11, 2022
@polyfloyd
Copy link
Owner

Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants