Skip to content

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

@mizusato

Description

@mizusato

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions