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: can't use aliased type as underlying type in type parameter #68935

Closed
skdltmxn opened this issue Aug 19, 2024 · 7 comments
Closed
Assignees
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@skdltmxn
Copy link

skdltmxn commented Aug 19, 2024

Go version

go version go1.23.0 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/gdpark/Library/Caches/go-build'
GOENV='/Users/gdpark/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/gdpark/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/gdpark/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/opt/go/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/opt/go/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/gdpark/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOARM64='v8.0'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/Users/gdpark/server/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/mz/71qhy0v14w188dvdrjyw499c0000gn/T/go-build1840556302=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

Starting from Go 1.23, I get 'invalid composite literal type T' error.
Please check the playground link which fails on Go 1.23.

https://go.dev/play/p/smVJSzGiGbn

I think I could not find any hint on this kind of change in release note, or was there?

What did you see happen?

Got 'invalid composite literal type T' error when building originally working codebase.

What did you expect to see?

Build should be successful.

@seankhliao seankhliao changed the title build: invalid composite literal type T error in Go 1.23 cmd/compile: can't use aliased type as underlying type in type parameter Aug 19, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Aug 19, 2024
@cuonglm cuonglm self-assigned this Aug 19, 2024
@cuonglm
Copy link
Member

cuonglm commented Aug 19, 2024

@gopherbot please backport this issue to go1.23 release.

This is a bug in compiler type checker without any workaround.

@gopherbot
Copy link
Contributor

Backport issue(s) opened: #68938 (for 1.23).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/606635 mentions this issue: types2, go/types: fix missing Unalias call in coreType

@dmitshur dmitshur added this to the Go1.24 milestone Aug 19, 2024
@dmitshur dmitshur added the NeedsFix The path to resolution is known, but the work has not been done. label Aug 19, 2024
@timothy-king
Copy link
Contributor

Duplicate of #68903

@timothy-king timothy-king marked this as a duplicate of #68903 Aug 19, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/606075 mentions this issue: go/types, types2: unalias tilde terms in underIs

gopherbot pushed a commit that referenced this issue Aug 20, 2024
Unalias the ~T terms during underIs. Before, if T was an alias
of U, it may pass T to the iteration function. The iterator
function expects an underlying type, under(U), to be passed.
This caused several bugs where underIs is used without
eventually taking the underlying type.

Updates #68935
Fixes #68903

Change-Id: Ie8691d8dddaea00e1dcba94d17c0f1b021fc49a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/606075
Reviewed-by: Robert Griesemer <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/607635 mentions this issue: [release-branch.go1.23] go/types, types2: unalias tilde terms in underIs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants