We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
const hello = `package aa import "fmt" func foo[A fmt.Stringer]() int { a := make([]A, 128) a[1].String() return len(a) } func bar() { foo[fmt.Stringer]() } ` func main() { // Parse the source files. fset := token.NewFileSet() f, err := parser.ParseFile(fset, "hello.go", hello, parser.ParseComments|parser.SkipObjectResolution) if err != nil { fmt.Print(err) // parse error return } files := []*ast.File{f} // Create the type-checker's package. pkg := types.NewPackage("hello", "") // Type-check the package, load dependencies. // Create and build the SSA program. _, _, err = ssautil.BuildPackage( &types.Config{Importer: importer.Default()}, fset, pkg, files, ssa.SanityCheckFunctions|ssa.GlobalDebug|ssa.LogSource|ssa.InstantiateGenerics) if err != nil { fmt.Print(err) // type error in some package return } }
$ go run . build package hello build hello.init @ - build hello.init @ - end build hello.foo @ hello.go:5:6 build hello.foo @ hello.go:5:6 end build hello.bar @ hello.go:11:6 build hello.bar @ hello.go:11:6 end build hello.foo[fmt.Stringer] @ hello.go:5:6 build hello.foo[fmt.Stringer] @ hello.go:5:6 end build package hello end panic: in hello.foo[fmt.Stringer]: cannot convert term slice t0[:128:int] ([]fmt.Stringer [within []fmt.Stringer]) to type []fmt.Stringer [within []fmt.Stringer] goroutine 1 [running]: golang.org/x/tools/go/ssa.emitConv.func1({0x726cd8, 0xc000244d60}, {0x726cd8, 0xc000244d40}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/emit.go:311 +0x339 golang.org/x/tools/go/ssa.emitConv.func2.1({0x726cd8?, 0xc000244d40?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/emit.go:320 +0x4c golang.org/x/tools/go/ssa.underIs.func1({0xc0001ef448?, 0x2?}, {0x726cd8?, 0xc000244d40?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/typeset.go:100 +0x34 golang.org/x/tools/go/ssa.typeset({0x726cd8?, 0xc000244d40?}, 0xc0001ef4a0) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/typeset.go:45 +0x103 golang.org/x/tools/go/ssa.underIs({0x726cd8?, 0xc000244d40?}, 0xc0001ef530?) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/typeset.go:99 +0x45 golang.org/x/tools/go/ssa.emitConv.func2({0x726cd8?, 0xc000244d60?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/emit.go:318 +0x58 golang.org/x/tools/go/ssa.underIs.func1({0xc0001b3f80?, 0x10?}, {0x726cd8?, 0xc000244d60?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/typeset.go:100 +0x34 golang.org/x/tools/go/ssa.typeset({0x726cd8?, 0xc000244d60?}, 0xc0001ef5c0) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/typeset.go:45 +0x103 golang.org/x/tools/go/ssa.underIs({0x726cd8?, 0xc000244d60?}, 0xc000244d60?) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/typeset.go:99 +0x45 golang.org/x/tools/go/ssa.emitConv(0xc000272e00, {0x7dd9cca91f90, 0xc0001d9300}, {0x726cd8, 0xc000244d40}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/emit.go:317 +0x67b golang.org/x/tools/go/ssa.emitStore(0xc000272e00, {0x729c18, 0xc000232fc0}, {0x7dd9cca91f90, 0xc0001d9300}, 0x3d) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/emit.go:418 +0x58 golang.org/x/tools/go/ssa.(*address).store(0xc0002418c0, 0xc000272e00, {0x7dd9cca91f90?, 0xc0001d9300?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/lvalue.go:42 +0x45 golang.org/x/tools/go/ssa.(*storebuf).emit(...) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:543 golang.org/x/tools/go/ssa.(*builder).assignStmt(0xc0002407e0, 0xc000272e00, {0xc0000141c0, 0x1, 0x3?}, {0xc0000141e0, 0x1, 0xc000241f80?}, 0x1) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:1223 +0x41c golang.org/x/tools/go/ssa.(*builder).stmt(0xc0002407e0, 0xc000272e00, {0x727880?, 0xc00010e500?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:2712 +0xd13 golang.org/x/tools/go/ssa.(*builder).stmtList(...) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:964 golang.org/x/tools/go/ssa.(*builder).stmt(0xc0002407e0, 0xc000272e00, {0x727790?, 0xc00007e8a0?}) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:2745 +0x1046 golang.org/x/tools/go/ssa.(*builder).buildFromSyntax(0xc0002407e0, 0xc000272e00) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:2951 +0x265 golang.org/x/tools/go/ssa.(*builder).buildFunction(0xc0002407e0?, 0xc000272e00) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:2904 +0x186 golang.org/x/tools/go/ssa.(*builder).iterate(0xc0002407e0) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:2889 +0x25 golang.org/x/tools/go/ssa.(*Package).build(0xc0001d8b80) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:3172 +0xce sync.(*Once).doSlow(0xc000234e10?, 0xc000032720?) /usr/lib/go/src/sync/once.go:76 +0xb4 sync.(*Once).Do(...) /usr/lib/go/src/sync/once.go:67 golang.org/x/tools/go/ssa.(*Package).Build(...) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/builder.go:3161 golang.org/x/tools/go/ssa/ssautil.BuildPackage(0xc0001308c0, 0xc00010e3c0, 0xc000032720, {0xc0000580b0, 0x1, 0x1}, 0x14c) /home/mateusz/go/pkg/mod/golang.org/x/tools@v0.30.0/go/ssa/ssautil/load.go:187 +0x475 main.main() /tmp/cc/main.go:44 +0x17c exit status 2
This happens only when ssa.InstantiateGenerics is passed to BuildPackage.
ssa.InstantiateGenerics
BuildPackage
CC @adonovan @timothy-king per https://dev.golang.org/owners
The text was updated successfully, but these errors were encountered:
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Sorry, something went wrong.
No branches or pull requests
This happens only when
ssa.InstantiateGenerics
is passed toBuildPackage
.CC @adonovan @timothy-king per https://dev.golang.org/owners
The text was updated successfully, but these errors were encountered: