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

go/types: "variable of type *invalid type" spurious error #24182

Closed
mvdan opened this issue Feb 28, 2018 · 5 comments
Closed

go/types: "variable of type *invalid type" spurious error #24182

mvdan opened this issue Feb 28, 2018 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@mvdan
Copy link
Member

mvdan commented Feb 28, 2018

$ cat ~/f.go
package p

var x *missing.Type

func f() {
        x.method()
}
$ go build gotype.go && ./gotype ~/f.go
/home/mvdan/f.go:3:8: undeclared name: missing
/home/mvdan/f.go:6:2: invalid operation: x (variable of type *invalid type) has no field or method method

This is clearly wrong - and the error goes away when I use var x missing.Type instead. Having a look in case it's a simple fix - seems to be because the operand's kind is not invalid when it should be.

/cc @griesemer

@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 28, 2018
@mvdan
Copy link
Member Author

mvdan commented Feb 28, 2018

Slightly simpler repro:

package p

var x *missingType

var _ = x.method

@griesemer griesemer added this to the Go1.11 milestone Feb 28, 2018
@mvdan
Copy link
Member Author

mvdan commented Feb 28, 2018

Forgot to mention - cmd/compile does not have this issue.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/97815 mentions this issue: go/types: prevent Type.Elem() == Typ[Invalid]

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/116735 mentions this issue: go/types: don't report errors referring to invalid types or operands

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/116775 mentions this issue: go/types: add missing test case for https://golang.org/cl/116735

gopherbot pushed a commit that referenced this issue Jun 6, 2018
Missed this in the prior submit.

For #24182.

Change-Id: If8349d39c80b7ff57bc0c857985f9e52241321b8
Reviewed-on: https://go-review.googlesource.com/116775
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Jun 6, 2019
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