You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In above mentioned snippet i.e https://go.dev/play/p/a4Xm3Eidkd0 , demoStr is declared as parameter to function but never used within function.
What did you expect to see?
In above mentioned snippet i.e. https://go.dev/play/p/a4Xm3Eidkd0 , This should raise error for demoStr as its not being used within function, agnostic of caller is passing or not. If its defined as parameter it should be consumed.
The text was updated successfully, but these errors were encountered:
sankets8793
changed the title
Error propagation not issued for function parameters if not used within function body.
Proposal: Error propagation not issued for function parameters if not used within function body.
Dec 19, 2024
sankets8793
changed the title
Proposal: Error propagation not issued for function parameters if not used within function body.
Proposal: runtime: Error propagation not issued for function parameters if not used within function body.
Dec 19, 2024
A function may not use one of its parameters in the following cases:
The function implements a method of an interface and does not need to use the parameter. In some cases, it may still be preferable to keep the parameter name instead of replacing it with the blank identifier.
A refactor has been done on an exported function, and the parameter is no longer used. For compatibility reasons, the parameter must be retained. From my perspective, it is better to keep the parameter name and document that it is no longer used, rather than replacing it with a blank identifier without any explanation in the documentation.
That said, the proposed change is not backward-compatible and would require modifying existing code.
Go version
go version go1.23.2 X:boringcrypto linux/amd64
Output of
go env
in your module/workspace:What did you do?
https://go.dev/play/p/a4Xm3Eidkd0
What did you see happen?
In above mentioned snippet i.e https://go.dev/play/p/a4Xm3Eidkd0 , demoStr is declared as parameter to function but never used within function.
What did you expect to see?
In above mentioned snippet i.e. https://go.dev/play/p/a4Xm3Eidkd0 , This should raise error for demoStr as its not being used within function, agnostic of caller is passing or not. If its defined as parameter it should be consumed.
The text was updated successfully, but these errors were encountered: