We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
go version 1.23
go env
GO111MODULE='' GOARCH='amd64' GOBIN='' GOCACHE='/home/smu/.cache/go-build' GOENV='/home/smu/.config/go/env' GOEXE='' GOEXPERIMENT='fieldtrack,boringcrypto' GOFLAGS='' GOHOSTARCH='amd64' GOHOSTOS='linux' GOINSECURE='' GOMODCACHE='/home/smu/go/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='linux' GOPATH='/home/smu/go' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/usr/lib/google-golang' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/usr/lib/google-golang/pkg/tool/linux_amd64' GOVCS='' GOVERSION='go1.23 [redacted] X:fieldtrack,boringcrypto' GODEBUG='' GOTELEMETRY='local' GOTELEMETRYDIR='/home/smu/.config/go/telemetry' GCCGO='gccgo' GOAMD64='v1' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' 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 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1689118444=/tmp/go-build -gno-record-gcc-switches'
I expected
if mErr := &MyError{}; errors.As(err1, &mErr) { ... }
to be parse correctly. See https://go.dev/play/p/XHkampOkowJ for a reproduction case.
Actual result of that playground snippet was:
./prog.go:23:10: syntax error: cannot use mErr := &MyError as value ./prog.go:26:1: syntax error: non-declaration statement outside function body
Changing the line
if mErr := &MyError{}; errors.As(err1, &mErr) {
into
if mErr := &(MyError{}); errors.As(err1, &mErr) {
makes the code work, but I would expect the first variant to work just as well.
A compiled program
The text was updated successfully, but these errors were encountered:
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
Sorry, something went wrong.
No branches or pull requests
Go version
go version 1.23
Output of
go env
in your module/workspace:What did you do?
I expected
to be parse correctly. See https://go.dev/play/p/XHkampOkowJ for a reproduction case.
Actual result of that playground snippet was:
./prog.go:23:10: syntax error: cannot use mErr := &MyError as value
./prog.go:26:1: syntax error: non-declaration statement outside function body
Changing the line
into
makes the code work, but I would expect the first variant to work just as well.
What did you see happen?
./prog.go:23:10: syntax error: cannot use mErr := &MyError as value
./prog.go:26:1: syntax error: non-declaration statement outside function body
What did you expect to see?
A compiled program
The text was updated successfully, but these errors were encountered: