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: implict dereference using constraints doesn't compile with -G=3 as expected #47713

Closed
abraithwaite opened this issue Aug 15, 2021 · 6 comments
Assignees
Milestone

Comments

@abraithwaite
Copy link
Contributor

@abraithwaite abraithwaite commented Aug 15, 2021

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

15:30:26 $ go version
go version devel go1.18-4d3cc847745 Thu Aug 12 20:22:27 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

Yes, on current HEAD of dev.typeparams.

What operating system and processor architecture are you using (go env)?

go env Output
15:31:08 $ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/abraithwaite/.cache/go-build"
GOENV="/home/abraithwaite/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/abraithwaite/Projects/golang/pkg/mod"
GOOS="linux"
GOPATH="/home/abraithwaite/Projects/golang"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/abraithwaite/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/abraithwaite/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-4d3cc847745 Thu Aug 12 20:22:27 2021 +0000"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build4018258502=/tmp/go-build -gno-record-gcc-switches"

What did you do? What did you expect to see? What did you see instead?

Using the following program, when compiling I expected an implicit de-reference of the method receiver:

https://github.com/abraithwaite/go-typeparams-issues/blob/master/bug-report-1/main.go

I expected no compilation error. This is what I saw instead:

15:32:18 $ go run -gcflags='-G=3' ./main.go
# command-line-arguments
<autogenerated>:1: cannot use .this (type *GenericSerializable[*main.SerDeString]) as type GenericSerializable[.shape.*uint8] in argument to GenericSerializable[.shape.*uint8].Send

I'm not sure why GenericSerializable is being passed as a pointer receiver instead of a value receiver as I've defined for .Send.

I saw this also: #47031 Maybe it's related? Seemed different enough to warrant opening this issue.

@mknyszek
Copy link
Contributor

@mknyszek mknyszek commented Aug 16, 2021

AFAIK dev.typeparams has been now merged into master, so I'm dropping that from the title.

Since this appears to be related to generics in the compiler frontend (?), CC @griesemer @mdempsky @danscales

Loading

@mknyszek mknyszek changed the title [dev.typeparams] implict dereference using constraints doesn't compile as expected cmd/compile: implict dereference using constraints doesn't compile with -G=3 as expected Aug 16, 2021
@mknyszek mknyszek added this to the Go1.18 milestone Aug 16, 2021
@abraithwaite
Copy link
Contributor Author

@abraithwaite abraithwaite commented Aug 16, 2021

I'll try it on the master branch too! Thanks for the update.

Loading

@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 16, 2021

This is an error reported by the compiler when writing object data to disk. The compiler front-end (types2, etc.) accepts this code just fine.

Loading

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Aug 16, 2021

I think this is actually an issue with method wrapper generation with -G=3 mode. The error message is because the generated code is not well typed.

(FWIW, it compiles and runs okay with GOEXPERIMENT=unified.)

Loading

@danscales danscales self-assigned this Aug 22, 2021
@danscales
Copy link

@danscales danscales commented Aug 23, 2021

This relates to some discrepancy in the naming of types, which leads to problems with wrapper generation. I'll have a fix in the next day or so.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 24, 2021

Change https://golang.org/cl/344613 mentions this issue: cmd/compile: fix naming of types inside instantiations

Loading

@gopherbot gopherbot closed this in 5b64381 Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants