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

cmd/compile: cannot use s (type [][]Typ) as type []go.shape.[]int_0 in assignment #55964

Closed
YueMengGu opened this issue Sep 30, 2022 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@YueMengGu
Copy link

YueMengGu commented Sep 30, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18.6 darwin/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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/xxx/.cache/go-build"
GOENV="/Users/xxx/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/xxx/Coding/go/pkg/mod"
GONOPROXY="*.everphoto.cn,git.smartisan.com"
GONOSUMDB="*.everphoto.cn,git.smartisan.com"
GOOS="darwin"
GOPATH="/Users/xxx/Coding/go"
GOPRIVATE="*.everphoto.cn,git.smartisan.com"
GOPROXY="https://goproxy.cn,https://proxy.golang.org,direct"
GOROOT="/Users/xxx/Coding/github/go"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/Users/xxx/Coding/github/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.6"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/xxx/Coding/tmp/testgo/go.mod"
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 -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/77/qcdftwkd6jb6945_b2k6n60h0000gp/T/go-build1909810451=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

compile the code with go build

package main

type iter[T any] struct {
	s []T
}

func StealSlice[T any](s []T) *iter[T] {
	return &iter[T]{s}
}

func Flatten[T any](s [][]T) {
	StealSlice(s)
}

func main() {
	type Typ int
	st := [][]Typ{{11}, {22, 33}}
	Flatten(st)
}

What did you expect to see?

compile succeed

What did you see instead?

./main.go:18:9: cannot use s (type [][]Status) as type []go.shape.[]int_0 in assignment

if add //go:noinline upper Flatten, compile succeed

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Sep 30, 2022
@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 30, 2022
@dmitshur dmitshur added this to the Backlog milestone Sep 30, 2022
@mdempsky
Copy link
Member

mdempsky commented Oct 5, 2022

This appears fixed in Go 1.19 (https://go.dev/play/p/oPCFs0AZEie) and tip (https://go.dev/play/p/oPCFs0AZEie?v=gotip). I don't think we're going to backport a fix for Go 1.18. Sorry.

@mdempsky mdempsky closed this as completed Oct 5, 2022
@YueMengGu
Copy link
Author

This appears fixed in Go 1.19 (https://go.dev/play/p/oPCFs0AZEie) and tip (https://go.dev/play/p/oPCFs0AZEie?v=gotip). I don't think we're going to backport a fix for Go 1.18. Sorry.

Thanks.

Another two questions,

  1. What‘s the root cause?
  2. Why not to backport, whether it is too compliex or something else

@golang golang locked and limited conversation to collaborators Oct 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants