Description
Go version
go version go1.24.4 openbsd/amd64
Output of go env
in your module/workspace:
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/jrick/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/jrick/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2338133049=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='openbsd'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/home/jrick/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='openbsd'
GOPATH='/home/jrick/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/jrick/src/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/jrick/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/home/jrick/src/go/pkg/tool/openbsd_amd64'
GOVCS=''
GOVERSION='go1.24.4'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
ParseAddr with the address string "fe80::1234:1%iwx0/104" returns an Addr that strings back to the same input, while I would expect this to fail (as ParseAddr does for inputs with prefixes without zones).
https://go.dev/play/p/sBg1XwXT-q3
This unexpected behavior occurred while attempting to write a single function that handled parsing both plain IPs and CIDR masked IPs, with implicit full masks when the bits were not specified, due to my function first calling netip.ParseAddr and returning without error if that succeeds, before falling back to netip.ParsePrefix (which does error on the very same input: https://go.dev/play/p/pcjj0dEEmhV).
What did you see happen?
No error.
What did you expect to see?
ParseAddr errors if input contains both zone and prefix, as it is documented to error if it includes a prefix (this does work as documented without a zone).