Open
Description
Describe the bug
got panic error when build code with more than 1 generic type parameters
panic: unhandled AST node: *ast.IndexListExpr [recovered]
panic: unhandled AST node: *ast.IndexListExpr
goroutine 1 [running]:
golang.org/x/tools/go/ast/astutil.Apply.func1()
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:46 +0xb8
panic({0x1049cdd40?, 0x140001a75a0?})
/Users/littlekey/.local/share/mise/installs/go/1.22.8/src/runtime/panic.go:770 +0x124
github.com/google/wire/internal/wire.copyAST.func1(0x1400035a360?)
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/internal/wire/copyast.go:392 +0x24a8
golang.org/x/tools/go/ast/astutil.(*application).apply(0x1400035a360, {0x104a20720?, 0x1400018f788?}, {0x1049ad5e8?, 0x1049ca820?}, 0x0?, {0x104a20540?, 0x14000352680?})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:452 +0x157c
golang.org/x/tools/go/ast/astutil.(*application).apply(0x1400035a360, {0x104a20428?, 0x140003526c0?}, {0x104947882?, 0x5?}, 0x1047b83d0?, {0x104a20720?, 0x1400018f788?})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:272 +0x1de8
golang.org/x/tools/go/ast/astutil.(*application).apply(0x1400035a360, {0x104a207c0?, 0x1400034c960?}, {0x1049478a2?, 0x0?}, 0x1400018f980?, {0x104a20428?, 0x140003526c0?})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:220 +0x1974
golang.org/x/tools/go/ast/astutil.(*application).applyList(0x1400035a360, {0x104a207c0, 0x1400034c960}, {0x1049478a2, 0x4})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:482 +0x78
golang.org/x/tools/go/ast/astutil.(*application).apply(0x1400035a360, {0x104a20450?, 0x140003580c0?}, {0x104948376?, 0xa?}, 0x1?, {0x104a207c0?, 0x1400034c960?})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:225 +0xd08
golang.org/x/tools/go/ast/astutil.(*application).apply(0x1400035a360, {0x104a201f8?, 0x1400034c9c0?}, {0x104947882?, 0x0?}, 0x5?, {0x104a20450?, 0x140003580c0?})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:298 +0x6f0
golang.org/x/tools/go/ast/astutil.(*application).apply(0x1400035a360, {0x104a20b50?, 0x140001a7590?}, {0x10494789e?, 0x10?}, 0x104b99420?, {0x104a201f8?, 0x1400034c9c0?})
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:426 +0x109c
golang.org/x/tools/go/ast/astutil.Apply({0x104a201f8, 0x1400034c9c0}, 0x0, 0x140001a7580)
/Users/littlekey/go/pkg/mod/golang.org/x/[email protected]/go/ast/astutil/rewrite.go:51 +0x10c
github.com/google/wire/internal/wire.copyAST({0x104a201f8, 0x1400034c9c0})
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/internal/wire/copyast.go:36 +0x7c
github.com/google/wire/internal/wire.(*gen).rewritePkgRefs(0x14000344e10, 0x140001c1a40, {0x104a201f8, 0x1400034c9c0})
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/internal/wire/wire.go:400 +0x58
github.com/google/wire/internal/wire.(*gen).writeAST(0x14000344e10, 0x1049e4660?, {0x104a201f8?, 0x1400034c9c0?})
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/internal/wire/wire.go:515 +0x28
github.com/google/wire/internal/wire.copyNonInjectorDecls(0x14000344e10, {0x140001804d0, 0x1, 0x10494957d?}, 0x140001c1a40)
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/internal/wire/wire.go:227 +0x26c
github.com/google/wire/internal/wire.Generate({0x104a21a10?, 0x104bfee40?}, {0x14000018104?, 0x140000ac9c0?}, {0x140000b0b08?, 0x65?, 0x40?}, {0x140000e7ba0?, 0x140000e7a88?, 0x10471cc20?}, ...)
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/internal/wire/wire.go:106 +0x310
main.(*genCmd).Execute(0x140000a27b0, {0x104a21a10, 0x104bfee40}, 0x140000cc8c0, {0x140000e7cd8?, 0x1049428d8?, 0x10?})
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/cmd/wire/main.go:139 +0x214
github.com/google/subcommands.(*Commander).Execute(0x140000ce000, {0x104a21a10, 0x104bfee40}, {0x0, 0x0, 0x0})
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/subcommands.go:209 +0x324
github.com/google/subcommands.Execute(...)
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/subcommands.go:492
main.main()
/Users/littlekey/go/pkg/mod/github.com/google/[email protected]/cmd/wire/main.go:73 +0x1124
To Reproduce
//go:build wireinject
// +build wireinject
package main
import (
"github.com/google/wire"
)
type Empty[T, T2 any] struct{}
func ProvideEmpty() *Empty[int, int] {
return &Empty[int, int]{}
}
func InitializeEmpty() *Empty[int, int] {
wire.Build(ProvideEmpty)
return nil
}
wire gen with above code: wire gen
Expected behavior
do not panic and generate code as well
Version
latest: v0.6.0
Additional context
Work well when use only 1 generic type parameter, like below:
//go:build wireinject
// +build wireinject
package main
import (
"github.com/google/wire"
)
type Empty[T any] struct{}
func ProvideEmpty() *Empty[int] {
return &Empty[int]{}
}
func InitializeEmpty() *Empty[int] {
wire.Build(ProvideEmpty)
return nil
}
Metadata
Assignees
Labels
No labels
Activity