Skip to content

Proposal: runtime: Error propagation not issued for function parameters if not used within function body. #70921

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

Closed
sankets8793 opened this issue Dec 19, 2024 · 5 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done. Proposal
Milestone

Comments

@sankets8793
Copy link

Go version

go version go1.23.2 X:boringcrypto linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT='boringcrypto'
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY='gitlab.eng.vmware.com,github.com/google/martian'
GONOSUMDB='*.eng.vmware.com'
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE='gitlab.eng.vmware.com,github.com/google/martian'
GOPROXY='http://avi-buildops-cache-server-blr.avilb.broadcom.net:9090,https://packages.vcfd.broadcom.net/srp-mds-go-remote,https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.2 X:boringcrypto'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='x86_64-vmk-linux-gnu-gcc'
CXX='x86_64-vmk-linux-gnu-g++'
CGO_ENABLED='0'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2580294929=/tmp/go-build -gno-record-gcc-switches'

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.

@sankets8793 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
@gopherbot gopherbot added this to the Proposal milestone Dec 19, 2024
@sankets8793
Copy link
Author

@gopherbot, please add labels NeedsFix

@gopherbot gopherbot added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 19, 2024
@sankets8793
Copy link
Author

@gopherbot, please add labels compiler/runtime

@sankets8793 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
@gazerro
Copy link
Contributor

gazerro commented 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.

@seankhliao
Copy link
Member

Duplicate of #39118

@seankhliao seankhliao marked this as a duplicate of #39118 Dec 19, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done. Proposal
Projects
None yet
Development

No branches or pull requests

5 participants