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

Comments

@mvdan
Copy link
Member

@mvdan 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 label Feb 28, 2018
@mvdan
Copy link
Member Author

@mvdan mvdan commented Feb 28, 2018

Slightly simpler repro:

package p

var x *missingType

var _ = x.method

Loading

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

@mvdan mvdan commented Feb 28, 2018

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 28, 2018

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Jun 6, 2018

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

Loading

@gopherbot gopherbot closed this in ca8ec69 Jun 6, 2018
@gopherbot
Copy link

@gopherbot gopherbot commented Jun 6, 2018

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

Loading

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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants