-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Open
Labels
LanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageLanguageChangeReviewDiscussed by language change review committeeDiscussed by language change review committeeProposal
Milestone
Description
This code is subtly wrong:
func f() (err os.Error) {
v, err := g();
if err != nil {
return;
}
if v {
v, err := h();
if err != nil {
return;
}
}
}
The := in the if statement causes a new err variable that shadows the
return parameter.
Maybe doing this should be an error. Maybe return parameters should be
special so that := doesn't ever shadow them. (I like the latter.)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
LanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageLanguageChangeReviewDiscussed by language change review committeeDiscussed by language change review committeeProposal