Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.18 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/holamson/.cache/go-build" GOENV="/home/holamson/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/holamson/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/holamson/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/holamson/.local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/holamson/.local/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.18" GCCGO="gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" GOWORK="" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1142584741=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Link on go.dev/play: https://go.dev/play/p/VgkIIishLsB
Complete runnable program:
package main
import "fmt"
type IntLike interface {
~int | ~int64 | ~int32 | ~int16 | ~int8
}
func Reduce[T any, U any, Uslice ~[]U](function func(T, U) T, sequence Uslice, initial T) T {
result := initial
for _, x := range sequence {
result = function(result, x)
}
return result
}
func min[T IntLike](x, y T) T {
if x < y {
return x
}
return y
}
// Min returns the minimum element of `nums`.
func Min[T IntLike, NumSlice ~[]T](nums NumSlice) T {
if len(nums) == 0 {
return T(0)
}
return Reduce(min[T], nums, nums[0])
}
// VarMin is the variadic version of Min.
func VarMin[T IntLike](nums ...T) T {
return Min(nums)
}
type myInt int
func main() {
fmt.Println(VarMin(myInt(1), myInt(2))) // OK
seq := []myInt{1, 2}
fmt.Println(Min(seq)) // OK
fmt.Println(VarMin(seq...)) // ERROR
}
What did you expect to see?
Expected output:
1
1
1
What did you see instead?
./prog.go:46:20: internal compiler error: assigning nums (type []myInt) to parameter nums (type go.shape.[]int_1)
Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
Go build failed.
Metadata
Metadata
Assignees
Type
Projects
Relationships
Development
No branches or pull requests
Activity
[-]affected/package: go1.18[/-][+]affected/package: go1.18 compiler error in unpacking arguments of variadic function[/+][-]affected/package: go1.18 compiler error in unpacking arguments of variadic function[/-][+]affected/package: go1.18 compiler error when unpacking arguments of variadic function[/+][-]affected/package: go1.18 compiler error when unpacking arguments of variadic function[/-][+]affected/package: go1.18 compiler error when unpacking arguments of variadic generic function[/+][-]affected/package: go1.18 compiler error when unpacking arguments of variadic generic function[/-][+]cmd/compile: go1.18 compiler error when unpacking arguments of variadic generic function[/+][-]cmd/compile: go1.18 compiler error when unpacking arguments of variadic generic function[/-][+]cmd/compile: ICE when unpacking arguments of variadic generic function[/+]mknyszek commentedon Mar 24, 2022
CC @griesemer @findleyr
mknyszek commentedon Mar 24, 2022
CC @dr2chase
ianlancetaylor commentedon Mar 24, 2022
CC @randall77
findleyr commentedon Mar 25, 2022
The error message here looks similar to #51909, though I have not confirmed that this is a dupe.
mdempsky commentedon Mar 25, 2022
Prints the expected output with
GOEXPERIMENT=unified
.gopherbot commentedon Mar 25, 2022
Change https://go.dev/cl/395854 mentions this issue:
cmd/compile: don't inline fn with shape params, but passed no shape arg
heschi commentedon May 11, 2022
ping: this is a release blocker that hasn't been updated in a while.
cmd/compile: don't inline fn with shape params, but passed no shape arg