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

Open
mdempsky opened this issue Nov 12, 2021 · 0 comments
Open

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

mdempsky opened this issue Nov 12, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Nov 12, 2021

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 this to the Go1.19 milestone Nov 12, 2021
@mdempsky mdempsky self-assigned this Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant