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

Panics when error type uses generics #10

Closed
mnrtks opened this issue May 18, 2022 · 3 comments · Fixed by #11
Closed

Panics when error type uses generics #10

mnrtks opened this issue May 18, 2022 · 3 comments · Fixed by #11

Comments

@mnrtks
Copy link

mnrtks commented May 18, 2022

It panics when I check the error type with generics.

I installed errname with following command.

go install github.com/Antonboom/errname@latest

Reproduction code.

package customerror

var _ error = (*Error[string])(nil)

type Error[T ~string] struct {
	Code T
}

func (e *Error[T]) Error() string {
	return string(e.Code)
}

Command result.

$ errname ./...
panic: no specification for type

goroutine 211 [running]:
github.com/Antonboom/errname/pkg/analyzer.run.func3({0x136d2c8?, 0xc00020d590?})
	/Users/minoru.takase/pkg/mod/github.com/!antonboom/errname@v0.1.6/pkg/analyzer/analyzer.go:65 +0x174
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc0005acd68, {0x14edab0?, 0x1?, 0x117c2cd?}, 0xc000203998)
	/Users/minoru.takase/pkg/mod/golang.org/x/tools@v0.1.10/go/ast/inspector/inspector.go:77 +0x9a
github.com/Antonboom/errname/pkg/analyzer.run(0xc000597520)
	/Users/minoru.takase/pkg/mod/github.com/!antonboom/errname@v0.1.6/pkg/analyzer/analyzer.go:55 +0x1fd
golang.org/x/tools/go/analysis/internal/checker.(*action).execOnce(0xc0006aa280)
	/Users/minoru.takase/pkg/mod/golang.org/x/tools@v0.1.10/go/analysis/internal/checker/checker.go:728 +0x9fe
sync.(*Once).doSlow(0x0?, 0x1257b60?)
	/Users/minoru.takase/.asdf/installs/golang/1.18/go/src/sync/once.go:68 +0xc2
sync.(*Once).Do(...)
	/Users/minoru.takase/.asdf/installs/golang/1.18/go/src/sync/once.go:59
golang.org/x/tools/go/analysis/internal/checker.(*action).exec(0xc00012e420?)
	/Users/minoru.takase/pkg/mod/golang.org/x/tools@v0.1.10/go/analysis/internal/checker/checker.go:616 +0x3d
golang.org/x/tools/go/analysis/internal/checker.execAll.func1(0x0?)
	/Users/minoru.takase/pkg/mod/golang.org/x/tools@v0.1.10/go/analysis/internal/checker/checker.go:604 +0x25
created by golang.org/x/tools/go/analysis/internal/checker.execAll
	/Users/minoru.takase/pkg/mod/golang.org/x/tools@v0.1.10/go/analysis/internal/checker/checker.go:610 +0x165
@Antonboom
Copy link
Owner

Thank u!
I'll try to fix this next weekend.

@Antonboom
Copy link
Owner

@mnrtks, please check :)

@mnrtks
Copy link
Author

mnrtks commented May 26, 2022

It worked! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants