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

range-val-in-closure: incorrectly flags struct key if the key has the same name as a range variable #637

Closed
twmb opened this issue Feb 15, 2022 · 1 comment · Fixed by #638
Labels

Comments

@twmb
Copy link

twmb commented Feb 15, 2022

package main

type t struct {
	key string
}

func main() {
	m := map[string]string{
		"a": "b",
	}

	for key := range m {
		myKey := key
		go func() {
			println(t{key: myKey})
		}()
	}
}
junk.go:15:14: range-val-in-closure: loop variable key captured by func literal (revive)
			println(t{key: myKey})
chavacava added a commit that referenced this issue Feb 15, 2022
@chavacava
Copy link
Collaborator

Hi @twmb, thanks for reporting the bug

chavacava added a commit that referenced this issue Feb 15, 2022
@chavacava chavacava added the bug label Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants