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 .this ( type *T[interface{}]) as type T[go.shape.interface {}_0] in T[go.shape.interface {}_0].Method #50486

Closed
csgura opened this issue Jan 7, 2022 · 5 comments
Labels
generics NeedsInvestigation

Comments

@csgura
Copy link

@csgura csgura commented Jan 7, 2022

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

$ go version
go version devel go1.18-07525e1 Fri Jan 7 00:15:59 2022 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

The gotip playground

What did you do?

https://gotipplay.golang.org/p/vuF7acfKTIv

What did you expect to see?

No Error.

What did you see instead?

# goerror
<autogenerated>:1: cannot use .this (type *fp.Seq[interface {}]) as type fp.Seq[go.shape.interface {}_0] in argument to fp.Seq[go.shape.interface {}_0].Append
<autogenerated>:1: cannot use .this (type *fp.Seq[interface {}]) as type fp.Seq[go.shape.interface {}_0] in argument to fp.Seq[go.shape.interface {}_0].Iterator
<autogenerated>:1: cannot use .this (type *fp.Seq[interface {}]) as type fp.Seq[go.shape.interface {}_0] in argument to fp.Seq[go.shape.interface {}_0].Size

If I remove ToSeq or Map method of Iterator, the error goes away.

@csgura csgura changed the title cmd/compile: cannot use .this ( type *T[interface{}]) as type T[go.shape.interface {}_0] in T[go.shape.interface {}_0] cmd/compile: cannot use .this ( type *T[interface{}]) as type T[go.shape.interface {}_0] in T[go.shape.interface {}_0].Method Jan 7, 2022
@cuonglm
Copy link
Member

@cuonglm cuonglm commented Jan 7, 2022

Maybe related #50419 cc @danscales

@cuonglm cuonglm added generics NeedsInvestigation labels Jan 7, 2022
@danscales
Copy link
Contributor

@danscales danscales commented Jan 7, 2022

Even though the gotip playground example is still failing, I can't seem to reproduce this locally. I create the module directory with main.go, go.mod, and fp/fp.go, and when I do 'go run main.go, everything runs fine. Everything runs fine locally at both 07525e1 and current tip 11b28e7 (and also the beta1 release becaeea). I also tried building with GOARCH=386 (since I thought the playground is sometimes a 32-bit machine), but that also worked fine. Is there something different about the gotip playground that I need to account for?

Can anyone else reproduce locally? I'm missing something.

@randall77 @cuonglm @ianlancetaylor

@danscales
Copy link
Contributor

@danscales danscales commented Jan 7, 2022

Oops, sorry about that, there was something mixed up in my local setup. Now I can reproduce it fine. Will take a look.

@danscales
Copy link
Contributor

@danscales danscales commented Jan 7, 2022

OK, I understand the issue and have a fix. (Not related to #50419, since that relates to the use of blanks for typeparams.)

@danscales danscales self-assigned this Jan 7, 2022
@gopherbot
Copy link

@gopherbot gopherbot commented Jan 10, 2022

Change https://golang.org/cl/377094 mentions this issue: cmd/compile: in typ0(), load base type before checking s.Def

jproberts pushed a commit to jproberts/go that referenced this issue Jun 21, 2022
The loading of the base type in typ0() may cause s.Def to be defined for
the instantiated type, so load the base type before checking s.Def.

Fixes golang#50486

Change-Id: Ic039bc8f774dda534f4ccd1f920220b7a10dede6
Reviewed-on: https://go-review.googlesource.com/c/go/+/377094
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generics NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

4 participants