go: x/tools/go/ssa: panic with Go 1.17 slice-to-array conversions
I’m not sure if this is a bug or not, considering that Go 1.17 is not out yet, but then again, Go 1.17 Beta 1 is already out. The original issue is mvdan/unparam#55. Using golang.org/x/tools with the latest master version (v0.1.5-0.20210629191230-72e4d1bb8d47), ssa.(*Package).Build seems to panic with:
panic: in command-line-arguments.main: cannot convert *t0 ([]int) to *[4]int
Full panic message:
panic: in command-line-arguments.main: cannot convert *t0 ([]int) to *[4]int
goroutine 720 [running]:
golang.org/x/tools/go/ssa.emitConv(0xc0001de500, {0x705fd8, 0xc0007b02a0}, {0x700820, 0xc000205e90})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/emit.go:242 +0x7b9
golang.org/x/tools/go/ssa.(*builder).expr0(0x665ac0, 0xc0001de500, {0x700d40, 0xc00009b4c0}, {0x7, {0x700820, 0xc000205e90}, {0x0, 0x0}})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:573 +0x925
golang.org/x/tools/go/ssa.(*builder).expr(0x0, 0xc0001de500, {0x700d40, 0xc00009b4c0})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:530 +0x19f
golang.org/x/tools/go/ssa.(*builder).addr(0x665ac0, 0xc0001de500, {0x701340, 0xc000450db0}, 0x0)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:417 +0xc8c
golang.org/x/tools/go/ssa.(*builder).expr(0x540eff, 0xc0001de500, {0x701340, 0xc000450db0})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:528 +0x145
golang.org/x/tools/go/ssa.(*builder).emitCallArgs(0xc00037b5c0, 0x7012b0, 0xc000495ce0, 0xc00009b500, {0x0, 0x0, 0x40cbe7})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:906 +0x7ed
golang.org/x/tools/go/ssa.(*builder).setCall(0x665ac0, 0xc0001de500, 0xc00009b500, 0xc0007b4240)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:969 +0x94
golang.org/x/tools/go/ssa.(*builder).expr0(0x665ac0, 0xc0001de500, {0x700d40, 0xc00009b500}, {0x7, {0x7008c0, 0xc0000b4468}, {0x0, 0x0}})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:596 +0x1f8e
golang.org/x/tools/go/ssa.(*builder).expr(0x604d01744c010008, 0xc0001de500, {0x700d40, 0xc00009b500})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:530 +0x19f
golang.org/x/tools/go/ssa.(*builder).stmt(0xcab743c011aa6, 0xc0001de500, {0x700ef0, 0xc000205dd0})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:1988 +0x135b
golang.org/x/tools/go/ssa.(*builder).stmtList(0x9b0f931c01228310, 0x1a5400057420010c, {0xc00020aaa0, 0x2, 0x274002022ff228a})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:790 +0x67
golang.org/x/tools/go/ssa.(*builder).stmt(0xc0001de500, 0xc0001de500, {0x700ce0, 0xc000183800})
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2105 +0x1331
golang.org/x/tools/go/ssa.(*builder).buildFunction(0x665f40, 0xc0001de500)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2198 +0x465
golang.org/x/tools/go/ssa.(*builder).buildFuncDecl(0x6652e0, 0xc00037b5c0, 0xc000183830)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2228 +0x154
golang.org/x/tools/go/ssa.(*Package).build(0xc00037b5c0)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2344 +0xd05
sync.(*Once).doSlow(0xc0004d97b8, 0x5fc89e)
/home/ainar/go/go1.17/src/sync/once.go:68 +0xd2
sync.(*Once).Do(...)
/home/ainar/go/go1.17/src/sync/once.go:59
golang.org/x/tools/go/ssa.(*Package).Build(...)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2263
golang.org/x/tools/go/ssa.(*Program).Build.func1(0x0)
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2247 +0x4c
created by golang.org/x/tools/go/ssa.(*Program).Build
/home/ainar/go/pkg/mod/golang.org/x/tools@v0.1.5-0.20210629191230-72e4d1bb8d47/go/ssa/builder.go:2246 +0x1a5
I’ve tested it using two analysers that use SSA, unparam and nilness, and both are panicking.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 17 (14 by maintainers)
It has been a few days without more input. The conversation seems to be heading towards adding a SliceToArrayPointer instruction. Please speak up in the next couple of days if you would prefer a different solution.
@timothy-king @dominikh I’m leaning to add new instruction, as now I realize that mixing slice to array pointer in
Convertseems make the current code more complicated.For reference, the compiler SSA backend also add new op for this conversion.