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
go version
$ go version go version go1.21.3 linux/amd64
yes
go env
$ go env GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/me/.cache/go-build' GOENV='/home/me/.config/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/me/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/me/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/local/go' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.21.3' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='gcc' CXX='g++' CGO_ENABLED='1' GOMOD='/dev/null' 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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1650394567=/tmp/go-build -gno-record-gcc-switches'
I wrot a simple code:
package main import "fmt" type ( foo int bar *foo ) func main() { var y bar fmt.Printf("%T\n", y) fmt.Printf("%T\n", (*int)(y)) // <- Why this doesn't work? fmt.Printf("%T\n", (*int)((*foo)(y))) }
The code should compile
./main.go:13:28: cannot convert y (variable of type bar) to type *int
The text was updated successfully, but these errors were encountered:
I'm pretty sure https://go.dev/doc/faq#convert_slice_with_same_underlying_type applies here even tho you are not using slices.
I feel this also applies https://github.com/golang/go/wiki/Questions
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions.
🙂
Sorry, something went wrong.
I see, thanks for your answer. I tought it is a bug and should be fixed (as these are not slices)
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I wrot a simple code:
What did you expect to see?
The code should compile
What did you see instead?
./main.go:13:28: cannot convert y (variable of type bar) to type *int
The text was updated successfully, but these errors were encountered: