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: unused variables not detected when captured by a closure #45054

Closed
mizusato opened this issue Mar 16, 2021 · 2 comments
Closed

cmd/compile: unused variables not detected when captured by a closure #45054

mizusato opened this issue Mar 16, 2021 · 2 comments

Comments

@mizusato
Copy link

@mizusato mizusato commented Mar 16, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

This snippet compiles:

var a int
var b int
(func() {
	a, b = (func()(int,int){ return 1,1 })()
})()

What did you expect to see?

It should not compile because a and b are unused variables.
The compiler accepts it silently while go vet correctly reports an error.

@agnivade agnivade added this to the Backlog milestone Mar 16, 2021
@agnivade
Copy link
Contributor

@agnivade agnivade commented Mar 16, 2021

Loading

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Mar 16, 2021

Duplicate of #3059.

Loading

@mdempsky mdempsky closed this Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants