From: Mark Freeman Date: Tue, 27 Jan 2026 15:53:21 +0000 (-0500) Subject: go/types, types2: rename Named.finite to Named.varSize X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ffb50fb7169f93c502e07868724b1f392267f696;p=gostls13.git go/types, types2: rename Named.finite to Named.varSize Change-Id: I81646c2753c2e44953b116138cb41d41a011ff08 Reviewed-on: https://go-review.googlesource.com/c/go/+/739561 LUCI-TryBot-Result: Go LUCI Auto-Submit: Mark Freeman Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index b11bacdecf..5965228585 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -1012,9 +1012,8 @@ func (check *Checker) hasVarSize(t Type) bool { // better error messages. switch t := Unalias(t).(type) { case *Named: - if t.stateHas(hasFinite) { - // TODO(mark): Rename t.finite to t.varSize to avoid inversion. - return !t.finite + if t.stateHas(hasVarSize) { + return t.varSize } if i, ok := check.objPathIdx[t.obj]; ok { @@ -1031,19 +1030,19 @@ func (check *Checker) hasVarSize(t Type) bool { t.mu.Lock() defer t.mu.Unlock() - // Careful, t.finite has lock-free readers. Since we might be racing - // another call to finiteSize, we have to avoid overwriting t.finite. + // Careful, t.varSize has lock-free readers. Since we might be racing + // another call to hasVarSize, we have to avoid overwriting t.varSize. // Otherwise, the race detector will be tripped. - if !t.stateHas(hasFinite) { - t.finite = !varSize - t.setState(hasFinite) + if !t.stateHas(hasVarSize) { + t.varSize = varSize + t.setState(hasVarSize) } return varSize case *Array: // The array length is already computed. If it was a valid length, it - // is finite; else, an error was reported in the computation. + // is constant; else, an error was reported in the computation. return check.hasVarSize(t.elem) case *Struct: diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go index 77e958139f..453ba1466b 100644 --- a/src/cmd/compile/internal/types2/named.go +++ b/src/cmd/compile/internal/types2/named.go @@ -115,7 +115,7 @@ type Named struct { fromRHS Type // the declaration RHS this type is derived from tparams *TypeParamList // type parameters, or nil underlying Type // underlying type, or nil - finite bool // whether the type has finite size + varSize bool // whether the type has variable size // methods declared for this type (not the method set of this type) // Signatures are type-checked lazily. @@ -147,10 +147,10 @@ type instance struct { // unpacked // └── hasMethods // └── hasUnder -// └── hasFinite +// └── hasVarSize // // That is, descent down the tree is mostly linear (initial through unpacked), except upon -// reaching the leaves (hasMethods, hasUnder, and hasFinite). A type may occupy any +// reaching the leaves (hasMethods, hasUnder, and hasVarSize). A type may occupy any // combination of the leaf states at once (they are independent states). // // To represent this independence, the set of active states is represented with a bit set. State @@ -164,7 +164,7 @@ type instance struct { // 11000 | unpacked, which implies lazyLoaded // 11100 | hasMethods, which implies unpacked (which in turn implies lazyLoaded) // 11010 | hasUnder, which implies unpacked ... -// 11001 | hasFinite, which implies unpacked ... +// 11001 | hasVarSize, which implies unpacked ... // 11110 | both hasMethods and hasUnder which implies unpacked ... // ... | (other combinations of leaf states) // @@ -177,7 +177,7 @@ const ( unpacked // methods might be unexpanded (for instances) hasMethods // methods are all expanded (for instances) hasUnder // underlying type is available - hasFinite // size finiteness is available + hasVarSize // varSize is available ) // NewNamed returns a new named type for the given type name, underlying type, and associated methods. @@ -306,8 +306,8 @@ func (n *Named) setState(m stateMask) { if m&hasUnder != 0 { assert(u) } - // hasFinite => unpacked - if m&hasFinite != 0 { + // hasVarSize => unpacked + if m&hasVarSize != 0 { assert(u) } } diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index bf0b8a4b4b..aea2997f32 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -1015,9 +1015,8 @@ func (check *Checker) hasVarSize(t Type) bool { // better error messages. switch t := Unalias(t).(type) { case *Named: - if t.stateHas(hasFinite) { - // TODO(mark): Rename t.finite to t.varSize to avoid inversion. - return !t.finite + if t.stateHas(hasVarSize) { + return t.varSize } if i, ok := check.objPathIdx[t.obj]; ok { @@ -1034,19 +1033,19 @@ func (check *Checker) hasVarSize(t Type) bool { t.mu.Lock() defer t.mu.Unlock() - // Careful, t.finite has lock-free readers. Since we might be racing - // another call to finiteSize, we have to avoid overwriting t.finite. + // Careful, t.varSize has lock-free readers. Since we might be racing + // another call to hasVarSize, we have to avoid overwriting t.varSize. // Otherwise, the race detector will be tripped. - if !t.stateHas(hasFinite) { - t.finite = !varSize - t.setState(hasFinite) + if !t.stateHas(hasVarSize) { + t.varSize = varSize + t.setState(hasVarSize) } return varSize case *Array: // The array length is already computed. If it was a valid length, it - // is finite; else, an error was reported in the computation. + // is constant; else, an error was reported in the computation. return check.hasVarSize(t.elem) case *Struct: diff --git a/src/go/types/named.go b/src/go/types/named.go index 42f33e6af4..5e0f44d7ff 100644 --- a/src/go/types/named.go +++ b/src/go/types/named.go @@ -118,7 +118,7 @@ type Named struct { fromRHS Type // the declaration RHS this type is derived from tparams *TypeParamList // type parameters, or nil underlying Type // underlying type, or nil - finite bool // whether the type has finite size + varSize bool // whether the type has variable size // methods declared for this type (not the method set of this type) // Signatures are type-checked lazily. @@ -150,10 +150,10 @@ type instance struct { // unpacked // └── hasMethods // └── hasUnder -// └── hasFinite +// └── hasVarSize // // That is, descent down the tree is mostly linear (initial through unpacked), except upon -// reaching the leaves (hasMethods, hasUnder, and hasFinite). A type may occupy any +// reaching the leaves (hasMethods, hasUnder, and hasVarSize). A type may occupy any // combination of the leaf states at once (they are independent states). // // To represent this independence, the set of active states is represented with a bit set. State @@ -167,7 +167,7 @@ type instance struct { // 11000 | unpacked, which implies lazyLoaded // 11100 | hasMethods, which implies unpacked (which in turn implies lazyLoaded) // 11010 | hasUnder, which implies unpacked ... -// 11001 | hasFinite, which implies unpacked ... +// 11001 | hasVarSize, which implies unpacked ... // 11110 | both hasMethods and hasUnder which implies unpacked ... // ... | (other combinations of leaf states) // @@ -180,7 +180,7 @@ const ( unpacked // methods might be unexpanded (for instances) hasMethods // methods are all expanded (for instances) hasUnder // underlying type is available - hasFinite // size finiteness is available + hasVarSize // varSize is available ) // NewNamed returns a new named type for the given type name, underlying type, and associated methods. @@ -309,8 +309,8 @@ func (n *Named) setState(m stateMask) { if m&hasUnder != 0 { assert(u) } - // hasFinite => unpacked - if m&hasFinite != 0 { + // hasVarSize => unpacked + if m&hasVarSize != 0 { assert(u) } }