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: build failure with unified IR ("no field or method") #49536

Closed
mdempsky opened this issue Nov 12, 2021 · 4 comments
Closed

cmd/compile: build failure with unified IR ("no field or method") #49536

mdempsky opened this issue Nov 12, 2021 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mdempsky
Copy link
Member

The source files below (distilled from https://go-review.googlesource.com/c/go/+/360015) are valid and should build, but they're failing when unified IR is enabled.

Notably the issue goes away if either a.F's return type is changed to *T[int] or either package is compiled with inlining disabled (i.e., -l). I suspect the problem is related to instantiating the type later, resulting in the methods not being added for some reason.

$ cat a.go
package a

func F() interface{} { return new(T[int]) }

type T[P any] int

func (x *T[P]) One() int { return x.Two() }
func (x *T[P]) Two() int { return 0 }

$ cat b.go
package b

import "./a"

var _ = a.F()

$ GOEXPERIMENT=unified go tool compile a.go
$ GOEXPERIMENT=unified go tool compile b.go
/tmp/a.go:7:36: a.x.Two undefined (type *a.T[int] has no field or method Two)
@mdempsky mdempsky added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 12, 2021
@mdempsky mdempsky added this to the Go1.19 milestone Nov 12, 2021
@mdempsky mdempsky self-assigned this Nov 12, 2021
@FiloSottile
Copy link
Contributor

I would like to submit https://go.dev/cl/360015 but it will break the linux-amd64-unified builder. How should I proceed?

@mdempsky
Copy link
Member Author

mdempsky commented Mar 4, 2022

Thanks for the heads up. I know the issue here (reentrancy issue in unified IR importer code), just need to prepare and submit a fix.

If you want to submit today, probably the easiest thing would be to keep the old files and use the goexperiment.unified build tag to control which ones are used. And then once I fix the issue in unified IR, we can remove the old files and the //go:build directives.

Otherwise, if you can wait a couple days, I should have a fix in for unified IR and you can submit the CL as prepared.

Sorry for the trouble.

@FiloSottile
Copy link
Contributor

My CL is still in review, it can definitely wait a week, no worries. Thank you for the quick reply!

@gopherbot
Copy link

Change https://go.dev/cl/390335 mentions this issue: cmd/compile: fix reentrancy issue in unified IR function body reading

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants