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: identifier resolved incorrectly #24026

Closed
alandonovan opened this issue Feb 22, 2018 · 2 comments
Closed

go/types: identifier resolved incorrectly #24026

alandonovan opened this issue Feb 22, 2018 · 2 comments

Comments

@alandonovan
Copy link
Contributor

@alandonovan alandonovan commented Feb 22, 2018

The type checker incorrectly resolves the reference in f(0) in the program below to the local variable f declared on the same line, not the package-level function f.

go version devel +a66af7280d Wed Feb 21 21:23:08 2018 +0000 linux/amd64
$ cat a.go
package main

func f(x int) string

func g() {
        f := func() string { return f(0) }
        f()
}
$ go run $GOROOT/src/go/types/gotype.go -- a.go
a.go:6:32: too many arguments
@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 22, 2018

This appears to only happen for short variable declarations; var f = func() { ... f() ... } seems to be ok. So there's at least a temporary work-around.

This bug was likely newly introduced with some of the 1.11 changes for go/types.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Feb 22, 2018

Change https://golang.org/cl/96177 mentions this issue: go/types: fix regression with short variable declarations

Loading

@gopherbot gopherbot closed this in 2465ae6 Feb 22, 2018
@golang golang locked and limited conversation to collaborators Feb 22, 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