diff options
| author | Joe Tsai <joetsai@digital-static.net> | 2022-08-23 19:27:49 -0700 |
|---|---|---|
| committer | Joseph Tsai <joetsai@digital-static.net> | 2022-09-07 16:41:47 +0000 |
| commit | cdb270cf0737a4752e5375b737eba83929f2b415 (patch) | |
| tree | 3a2e17b47127be5b1f57e55a32fd959ef87c9c8a /src/reflect | |
| parent | 027ff3f47d5d6557067324c342c8e14d7da1cf7a (diff) | |
| download | go-cdb270cf0737a4752e5375b737eba83929f2b415.tar.xz | |
reflect: fix stale Value.kind documentation
The lowests fives bits are the kind, and the next five bits are attributes,
not the other way around.
Change-Id: I5e1d13b195b766e99f66bb1227cc7f84e85dc49d
Reviewed-on: https://go-review.googlesource.com/c/go/+/425185
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/reflect')
| -rw-r--r-- | src/reflect/value.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/reflect/value.go b/src/reflect/value.go index 5276af6fd6..6830057d61 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -45,17 +45,19 @@ type Value struct { ptr unsafe.Pointer // flag holds metadata about the value. - // The lowest bits are flag bits: + // + // The lowest five bits give the Kind of the value, mirroring typ.Kind(). + // + // The next set of bits are flag bits: // - flagStickyRO: obtained via unexported not embedded field, so read-only // - flagEmbedRO: obtained via unexported embedded field, so read-only // - flagIndir: val holds a pointer to the data - // - flagAddr: v.CanAddr is true (implies flagIndir) + // - flagAddr: v.CanAddr is true (implies flagIndir and ptr is non-nil) // - flagMethod: v is a method value. - // The next five bits give the Kind of the value. - // This repeats typ.Kind() except for method values. - // The remaining 23+ bits give a method number for method values. - // If flag.kind() != Func, code can assume that flagMethod is unset. // If ifaceIndir(typ), code can assume that flagIndir is set. + // + // The remaining 22+ bits give a method number for method values. + // If flag.kind() != Func, code can assume that flagMethod is unset. flag // A method value represents a curried method invocation |
