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
proposal: spec: disallow unused assignment to return variable #7485
Labels
FrozenDueToAge
LanguageChange
Proposal-FinalCommentPeriod
v2
A language change or incompatible library change
Milestone
Comments
The rationale behind excluding return values was that func foo() (x int) { return 5 } assigns to x (implicitly) and doesn't use the result. The spec says "Implementation restriction: A compiler may make it illegal to declare a variable inside a function body if the variable is never used." I don't think x is inside the function body here. Both because of that and because gc has accepted the program already, I don't think we can change this for Go 1.x. Labels changed: added go2, removed release-go1.3maybe. |
rsc
changed the title
spec: assignment to otherwise unused return variable not detected as error
spec: disallow unused assignment to return variable
Jun 17, 2017
rsc
changed the title
spec: disallow unused assignment to return variable
proposal: spec: disallow unused assignment to return variable
Jun 17, 2017
ianlancetaylor
added
the
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
label
Dec 13, 2017
gopherbot
removed
the
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
label
Aug 16, 2019
gopherbot
added
the
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
label
Sep 3, 2019
Implementing this in the language could be done, but we would have to pay attention to any use of a |
ianlancetaylor
added
Proposal-FinalCommentPeriod
and removed
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
labels
Apr 21, 2020
No further comments. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
FrozenDueToAge
LanguageChange
Proposal-FinalCommentPeriod
v2
A language change or incompatible library change
The text was updated successfully, but these errors were encountered: