aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile
diff options
context:
space:
mode:
authorMark Freeman <mark@golang.org>2026-02-04 15:30:17 -0500
committerGopher Robot <gobot@golang.org>2026-02-05 13:43:58 -0800
commit052e64e9386c9e1d1dcc83d5373e7dee66f67de2 (patch)
tree01816f8f9b79dfca5dc4c428739a0786ea778273 /src/cmd/compile
parentc34b99a5e20307a55a047543f6b48d8a28d830b5 (diff)
downloadgo-052e64e9386c9e1d1dcc83d5373e7dee66f67de2.tar.xz
go/types, types2: mechanically rename operand.typ to operand.typ_
Change-Id: Iba87b8bc6188e5e784542f2c0f6f4c4cc3f70b28 Reviewed-on: https://go-review.googlesource.com/c/go/+/742022 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <markfreeman@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r--src/cmd/compile/internal/types2/api_predicates.go4
-rw-r--r--src/cmd/compile/internal/types2/assignments.go30
-rw-r--r--src/cmd/compile/internal/types2/builtins.go156
-rw-r--r--src/cmd/compile/internal/types2/call.go84
-rw-r--r--src/cmd/compile/internal/types2/const.go12
-rw-r--r--src/cmd/compile/internal/types2/conversions.go28
-rw-r--r--src/cmd/compile/internal/types2/expr.go162
-rw-r--r--src/cmd/compile/internal/types2/index.go58
-rw-r--r--src/cmd/compile/internal/types2/infer.go14
-rw-r--r--src/cmd/compile/internal/types2/literals.go8
-rw-r--r--src/cmd/compile/internal/types2/operand.go42
-rw-r--r--src/cmd/compile/internal/types2/range.go16
-rw-r--r--src/cmd/compile/internal/types2/recording.go6
-rw-r--r--src/cmd/compile/internal/types2/stmt.go28
-rw-r--r--src/cmd/compile/internal/types2/typexpr.go10
15 files changed, 329 insertions, 329 deletions
diff --git a/src/cmd/compile/internal/types2/api_predicates.go b/src/cmd/compile/internal/types2/api_predicates.go
index d2473804c0..a1be5de5f4 100644
--- a/src/cmd/compile/internal/types2/api_predicates.go
+++ b/src/cmd/compile/internal/types2/api_predicates.go
@@ -28,7 +28,7 @@ func AssertableTo(V *Interface, T Type) bool {
// The behavior of AssignableTo is unspecified if V or T is Typ[Invalid] or an
// uninstantiated generic type.
func AssignableTo(V, T Type) bool {
- x := operand{mode: value, typ: V}
+ x := operand{mode: value, typ_: V}
ok, _ := x.assignableTo(nil, T, nil) // check not needed for non-constant x
return ok
}
@@ -39,7 +39,7 @@ func AssignableTo(V, T Type) bool {
// The behavior of ConvertibleTo is unspecified if V or T is Typ[Invalid] or an
// uninstantiated generic type.
func ConvertibleTo(V, T Type) bool {
- x := operand{mode: value, typ: V}
+ x := operand{mode: value, typ_: V}
return x.convertibleTo(nil, T, nil) // check not needed for non-constant x
}
diff --git a/src/cmd/compile/internal/types2/assignments.go b/src/cmd/compile/internal/types2/assignments.go
index 87f5c8beea..03ad0085ba 100644
--- a/src/cmd/compile/internal/types2/assignments.go
+++ b/src/cmd/compile/internal/types2/assignments.go
@@ -37,7 +37,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
return
}
- if isUntyped(x.typ) {
+ if isUntyped(x.typ_) {
target := T
// spec: "If an untyped constant is assigned to a variable of interface
// type or the blank identifier, the constant is first converted to type
@@ -52,16 +52,16 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
return
}
} else if T == nil || isNonTypeParamInterface(T) {
- target = Default(x.typ)
+ target = Default(x.typ_)
}
} else { // go/types
if T == nil || isNonTypeParamInterface(T) {
- if T == nil && x.typ == Typ[UntypedNil] {
+ if T == nil && x.typ_ == Typ[UntypedNil] {
check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
x.mode = invalid
return
}
- target = Default(x.typ)
+ target = Default(x.typ_)
}
}
newType, val, code := check.implicitTypeAndValue(x, target)
@@ -83,15 +83,15 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
x.val = val
check.updateExprVal(x.expr, val)
}
- if newType != x.typ {
- x.typ = newType
+ if newType != x.typ_ {
+ x.typ_ = newType
check.updateExprType(x.expr, newType, false)
}
}
// x.typ is typed
// A generic (non-instantiated) function value cannot be assigned to a variable.
- if sig, _ := x.typ.Underlying().(*Signature); sig != nil && sig.TypeParams().Len() > 0 {
+ if sig, _ := x.typ_.Underlying().(*Signature); sig != nil && sig.TypeParams().Len() > 0 {
check.errorf(x, WrongTypeArgCount, "cannot use generic function %s without instantiation in %s", x, context)
x.mode = invalid
return
@@ -116,7 +116,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
}
func (check *Checker) initConst(lhs *Const, x *operand) {
- if x.mode == invalid || !isValid(x.typ) || !isValid(lhs.typ) {
+ if x.mode == invalid || !isValid(x.typ_) || !isValid(lhs.typ) {
if lhs.typ == nil {
lhs.typ = Typ[Invalid]
}
@@ -131,11 +131,11 @@ func (check *Checker) initConst(lhs *Const, x *operand) {
}
return
}
- assert(isConstType(x.typ))
+ assert(isConstType(x.typ_))
// If the lhs doesn't have a type yet, use the type of x.
if lhs.typ == nil {
- lhs.typ = x.typ
+ lhs.typ = x.typ_
}
check.assignment(x, lhs.typ, "constant declaration")
@@ -151,7 +151,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) {
// or Typ[Invalid] in case of an error.
// If the initialization check fails, x.mode is set to invalid.
func (check *Checker) initVar(lhs *Var, x *operand, context string) {
- if x.mode == invalid || !isValid(x.typ) || !isValid(lhs.typ) {
+ if x.mode == invalid || !isValid(x.typ_) || !isValid(lhs.typ) {
if lhs.typ == nil {
lhs.typ = Typ[Invalid]
}
@@ -161,7 +161,7 @@ func (check *Checker) initVar(lhs *Var, x *operand, context string) {
// If lhs doesn't have a type yet, use the type of x.
if lhs.typ == nil {
- typ := x.typ
+ typ := x.typ_
if isUntyped(typ) {
// convert untyped types to default types
if typ == Typ[UntypedNil] {
@@ -216,7 +216,7 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type {
check.usedVars[v] = v_used // restore v.used
}
- if x.mode == invalid || !isValid(x.typ) {
+ if x.mode == invalid || !isValid(x.typ_) {
return Typ[Invalid]
}
@@ -240,7 +240,7 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type {
return Typ[Invalid]
}
- return x.typ
+ return x.typ_
}
// assignVar checks the assignment lhs = rhs (if x == nil), or lhs = x (if x != nil).
@@ -278,7 +278,7 @@ func (check *Checker) assignVar(lhs, rhs syntax.Expr, x *operand, context string
// operandTypes returns the list of types for the given operands.
func operandTypes(list []*operand) (res []Type) {
for _, x := range list {
- res = append(res, x.typ)
+ res = append(res, x.typ_)
}
return res
}
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go
index 5fa0e6c6f0..b544dd94f0 100644
--- a/src/cmd/compile/internal/types2/builtins.go
+++ b/src/cmd/compile/internal/types2/builtins.go
@@ -109,7 +109,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
if ok, _ := x.assignableTo(check, NewSlice(universeByte), nil); ok {
y := args[1]
hasString := false
- for _, u := range typeset(y.typ) {
+ for _, u := range typeset(y.typ_) {
if s, _ := u.(*Slice); s != nil && Identical(s.elem, universeByte) {
// typeset ⊇ {[]byte}
} else if isString(u) {
@@ -122,7 +122,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
if y != nil && hasString {
// setting the signature also signals that we're done
- sig = makeSig(x.typ, x.typ, y.typ)
+ sig = makeSig(x.typ_, x.typ_, y.typ_)
sig.variadic = true
}
}
@@ -131,7 +131,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// general case
if sig == nil {
// check arguments by creating custom signature
- sig = makeSig(x.typ, x.typ, NewSlice(E)) // []E required for variadic signature
+ sig = makeSig(x.typ_, x.typ_, NewSlice(E)) // []E required for variadic signature
sig.variadic = true
check.arguments(call, sig, nil, nil, args, nil) // discard result (we know the result type)
// ok to continue even if check.arguments reported errors
@@ -148,7 +148,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// len(x)
mode := invalid
var val constant.Value
- switch t := arrayPtrDeref(x.typ.Underlying()).(type) {
+ switch t := arrayPtrDeref(x.typ_.Underlying()).(type) {
case *Basic:
if isString(t) && id == _Len {
if x.mode == constant_ {
@@ -183,10 +183,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
case *Interface:
- if !isTypeParam(x.typ) {
+ if !isTypeParam(x.typ_) {
break
}
- if underIs(x.typ, func(u Type) bool {
+ if underIs(x.typ_, func(u Type) bool {
switch t := arrayPtrDeref(u).(type) {
case *Basic:
if isString(t) && id == _Len {
@@ -207,7 +207,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
if mode == invalid {
// avoid error if underlying type is invalid
- if isValid(x.typ.Underlying()) {
+ if isValid(x.typ_.Underlying()) {
code := InvalidCap
if id == _Len {
code = InvalidLen
@@ -219,18 +219,18 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// record the signature before changing x.typ
if check.recordTypes() && mode != constant_ {
- check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ_))
}
x.mode = mode
- x.typ = Typ[Int]
+ x.typ_ = Typ[Int]
x.val = val
case _Clear:
// clear(m)
check.verifyVersionf(call.Fun, go1_21, "clear")
- if !underIs(x.typ, func(u Type) bool {
+ if !underIs(x.typ_, func(u Type) bool {
switch u.(type) {
case *Map, *Slice:
return true
@@ -243,12 +243,12 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
x.mode = novalue
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(nil, x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(nil, x.typ_))
}
case _Close:
// close(c)
- if !underIs(x.typ, func(u Type) bool {
+ if !underIs(x.typ_, func(u Type) bool {
uch, _ := u.(*Chan)
if uch == nil {
check.errorf(x, InvalidClose, invalidOp+"cannot close non-channel %s", x)
@@ -264,7 +264,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
x.mode = novalue
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(nil, x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(nil, x.typ_))
}
case _Complex:
@@ -273,10 +273,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// convert or check untyped arguments
d := 0
- if isUntyped(x.typ) {
+ if isUntyped(x.typ_) {
d |= 1
}
- if isUntyped(y.typ) {
+ if isUntyped(y.typ_) {
d |= 2
}
switch d {
@@ -284,10 +284,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// x and y are typed => nothing to do
case 1:
// only x is untyped => convert to type of y
- check.convertUntyped(x, y.typ)
+ check.convertUntyped(x, y.typ_)
case 2:
// only y is untyped => convert to type of x
- check.convertUntyped(y, x.typ)
+ check.convertUntyped(y, x.typ_)
case 3:
// x and y are untyped =>
// 1) if both are constants, convert them to untyped
@@ -299,8 +299,8 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// because shifts of floats are not permitted)
if x.mode == constant_ && y.mode == constant_ {
toFloat := func(x *operand) {
- if isNumeric(x.typ) && constant.Sign(constant.Imag(x.val)) == 0 {
- x.typ = Typ[UntypedFloat]
+ if isNumeric(x.typ_) && constant.Sign(constant.Imag(x.val)) == 0 {
+ x.typ_ = Typ[UntypedFloat]
}
}
toFloat(x)
@@ -317,8 +317,8 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
// both argument types must be identical
- if !Identical(x.typ, y.typ) {
- check.errorf(x, InvalidComplex, invalidOp+"%v (mismatched types %s and %s)", call, x.typ, y.typ)
+ if !Identical(x.typ_, y.typ_) {
+ check.errorf(x, InvalidComplex, invalidOp+"%v (mismatched types %s and %s)", call, x.typ_, y.typ_)
return
}
@@ -340,7 +340,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
resTyp := check.applyTypeFunc(f, x, id)
if resTyp == nil {
- check.errorf(x, InvalidComplex, invalidArg+"arguments have type %s, expected floating-point", x.typ)
+ check.errorf(x, InvalidComplex, invalidArg+"arguments have type %s, expected floating-point", x.typ_)
return
}
@@ -352,10 +352,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
if check.recordTypes() && x.mode != constant_ {
- check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ, x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ_, x.typ_))
}
- x.typ = resTyp
+ x.typ_ = resTyp
case _Copy:
// copy(x, y []E) int
@@ -372,7 +372,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
var special bool
if ok, _ := x.assignableTo(check, NewSlice(universeByte), nil); ok {
special = true
- for _, u := range typeset(y.typ) {
+ for _, u := range typeset(y.typ_) {
if s, _ := u.(*Slice); s != nil && Identical(s.elem, universeByte) {
// typeset ⊇ {[]byte}
} else if isString(u) {
@@ -396,7 +396,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
srcE, err := sliceElem(y)
if err != nil {
// If we have a string, for a better error message proceed with byte element type.
- if !allString(y.typ) {
+ if !allString(y.typ_) {
check.errorf(y, InvalidCopy, "invalid copy: %s", err.format(check))
return
}
@@ -409,16 +409,16 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ, y.typ))
+ check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ_, y.typ_))
}
x.mode = value
- x.typ = Typ[Int]
+ x.typ_ = Typ[Int]
case _Delete:
// delete(map_, key)
// map_ must be a map type or a type parameter describing map types.
// The key cannot be a type parameter for now.
- map_ := x.typ
+ map_ := x.typ_
var key Type
if !underIs(map_, func(u Type) bool {
map_, _ := u.(*Map)
@@ -452,12 +452,12 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// real(complexT) floatT
// convert or check untyped argument
- if isUntyped(x.typ) {
+ if isUntyped(x.typ_) {
if x.mode == constant_ {
// an untyped constant number can always be considered
// as a complex constant
- if isNumeric(x.typ) {
- x.typ = Typ[UntypedComplex]
+ if isNumeric(x.typ_) {
+ x.typ_ = Typ[UntypedComplex]
}
} else {
// an untyped non-constant argument may appear if
@@ -494,7 +494,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
if id == _Real {
code = InvalidReal
}
- check.errorf(x, code, invalidArg+"argument has type %s, expected complex type", x.typ)
+ check.errorf(x, code, invalidArg+"argument has type %s, expected complex type", x.typ_)
return
}
@@ -510,10 +510,10 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
if check.recordTypes() && x.mode != constant_ {
- check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ_))
}
- x.typ = resTyp
+ x.typ_ = resTyp
case _Make:
// make(T, n)
@@ -569,9 +569,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// safe to continue
}
x.mode = value
- x.typ = T
+ x.typ_ = T
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, types...))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, types...))
}
case _Max, _Min:
@@ -589,7 +589,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}
- if !allOrdered(a.typ) {
+ if !allOrdered(a.typ_) {
check.errorf(a, InvalidMinMaxOperand, invalidArg+"%s cannot be ordered", a)
return
}
@@ -601,8 +601,8 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}
- if !Identical(x.typ, a.typ) {
- check.errorf(a, MismatchedTypes, invalidArg+"mismatched types %s (previous argument) and %s (type of %s)", x.typ, a.typ, a.expr)
+ if !Identical(x.typ_, a.typ_) {
+ check.errorf(a, MismatchedTypes, invalidArg+"mismatched types %s (previous argument) and %s (type of %s)", x.typ_, a.typ_, a.expr)
return
}
@@ -628,15 +628,15 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// Use the final type computed above for all arguments.
for _, a := range args {
- check.updateExprType(a.expr, x.typ, true)
+ check.updateExprType(a.expr, x.typ_, true)
}
if check.recordTypes() && x.mode != constant_ {
types := make([]Type, nargs)
for i := range types {
- types[i] = x.typ
+ types[i] = x.typ_
}
- check.recordBuiltinType(call.Fun, makeSig(x.typ, types...))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, types...))
}
case _New:
@@ -650,26 +650,26 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
case typexpr:
// new(T)
- check.validVarType(arg, x.typ)
+ check.validVarType(arg, x.typ_)
default:
// new(expr)
- if isUntyped(x.typ) {
+ if isUntyped(x.typ_) {
// check for overflow and untyped nil
check.assignment(x, nil, "argument to new")
if x.mode == invalid {
return
}
- assert(isTyped(x.typ))
+ assert(isTyped(x.typ_))
}
// report version error only if there are no other errors
check.verifyVersionf(call.Fun, go1_26, "new(%s)", arg)
}
- T := x.typ
+ T := x.typ_
x.mode = value
- x.typ = NewPointer(T)
+ x.typ_ = NewPointer(T)
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, T))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, T))
}
case _Panic:
@@ -708,7 +708,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
if a.mode == invalid {
return
}
- params[i] = a.typ
+ params[i] = a.typ_
}
}
@@ -720,9 +720,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
case _Recover:
// recover() interface{}
x.mode = value
- x.typ = &emptyInterface
+ x.typ_ = &emptyInterface
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_))
}
case _Add:
@@ -740,9 +740,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
x.mode = value
- x.typ = Typ[UnsafePointer]
+ x.typ_ = Typ[UnsafePointer]
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, x.typ, y.typ))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, x.typ_, y.typ_))
}
case _Alignof:
@@ -752,17 +752,17 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}
- if check.hasVarSize(x.typ) {
+ if check.hasVarSize(x.typ_) {
x.mode = value
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ_))
}
} else {
x.mode = constant_
- x.val = constant.MakeInt64(check.conf.alignof(x.typ))
+ x.val = constant.MakeInt64(check.conf.alignof(x.typ_))
// result is constant - no need to record signature
}
- x.typ = Typ[Uintptr]
+ x.typ_ = Typ[Uintptr]
case _Offsetof:
// unsafe.Offsetof(x T) uintptr, where x must be a selector
@@ -780,7 +780,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}
- base := derefStructPtr(x.typ)
+ base := derefStructPtr(x.typ_)
sel := selx.Sel.Value
obj, index, indirect := lookupFieldOrMethod(base, false, check.pkg, sel, false)
switch obj.(type) {
@@ -831,7 +831,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
x.val = constant.MakeInt64(offs)
// result is constant - no need to record signature
}
- x.typ = Typ[Uintptr]
+ x.typ_ = Typ[Uintptr]
case _Sizeof:
// unsafe.Sizeof(x T) uintptr
@@ -840,13 +840,13 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
return
}
- if check.hasVarSize(x.typ) {
+ if check.hasVarSize(x.typ_) {
x.mode = value
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ))
+ check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ_))
}
} else {
- size := check.conf.sizeof(x.typ)
+ size := check.conf.sizeof(x.typ_)
if size < 0 {
check.errorf(x, TypeTooLarge, "%s is too large", x)
return
@@ -855,13 +855,13 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
x.val = constant.MakeInt64(size)
// result is constant - no need to record signature
}
- x.typ = Typ[Uintptr]
+ x.typ_ = Typ[Uintptr]
case _Slice:
// unsafe.Slice(ptr *T, len IntegerType) []T
check.verifyVersionf(call.Fun, go1_17, "unsafe.Slice")
- u, _ := commonUnder(x.typ, nil)
+ u, _ := commonUnder(x.typ_, nil)
ptr, _ := u.(*Pointer)
if ptr == nil {
check.errorf(x, InvalidUnsafeSlice, invalidArg+"%s is not a pointer", x)
@@ -874,16 +874,16 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
x.mode = value
- x.typ = NewSlice(ptr.base)
+ x.typ_ = NewSlice(ptr.base)
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, ptr, y.typ))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, ptr, y.typ_))
}
case _SliceData:
// unsafe.SliceData(slice []T) *T
check.verifyVersionf(call.Fun, go1_20, "unsafe.SliceData")
- u, _ := commonUnder(x.typ, nil)
+ u, _ := commonUnder(x.typ_, nil)
slice, _ := u.(*Slice)
if slice == nil {
check.errorf(x, InvalidUnsafeSliceData, invalidArg+"%s is not a slice", x)
@@ -891,9 +891,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
x.mode = value
- x.typ = NewPointer(slice.elem)
+ x.typ_ = NewPointer(slice.elem)
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, slice))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, slice))
}
case _String:
@@ -911,9 +911,9 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
x.mode = value
- x.typ = Typ[String]
+ x.typ_ = Typ[String]
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, NewPointer(universeByte), y.typ))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, NewPointer(universeByte), y.typ_))
}
case _StringData:
@@ -926,16 +926,16 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
}
x.mode = value
- x.typ = NewPointer(universeByte)
+ x.typ_ = NewPointer(universeByte)
if check.recordTypes() {
- check.recordBuiltinType(call.Fun, makeSig(x.typ, Typ[String]))
+ check.recordBuiltinType(call.Fun, makeSig(x.typ_, Typ[String]))
}
case _Assert:
// assert(pred) causes a typechecker error if pred is false.
// The result of assert is the value of pred if there is no error.
// Note: assert is only available in self-test mode.
- if x.mode != constant_ || !isBoolean(x.typ) {
+ if x.mode != constant_ || !isBoolean(x.typ_) {
check.errorf(x, Test, invalidArg+"%s is not a boolean constant", x)
return
}
@@ -984,7 +984,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
// or a type error if x is not a slice (or a type set of slices).
func sliceElem(x *operand) (Type, *typeError) {
var E Type
- for _, u := range typeset(x.typ) {
+ for _, u := range typeset(x.typ_) {
s, _ := u.(*Slice)
if s == nil {
if x.isNil() {
@@ -1070,7 +1070,7 @@ func (check *Checker) hasVarSize(t Type) bool {
// applyTypeFunc returns nil.
// If x is not a type parameter, the result is f(x).
func (check *Checker) applyTypeFunc(f func(Type) Type, x *operand, id builtinId) Type {
- if tp, _ := Unalias(x.typ).(*TypeParam); tp != nil {
+ if tp, _ := Unalias(x.typ_).(*TypeParam); tp != nil {
// Test if t satisfies the requirements for the argument
// type and collect possible result types at the same time.
var terms []*Term
@@ -1114,7 +1114,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x *operand, id builtinId)
return ptyp
}
- return f(x.typ)
+ return f(x.typ_)
}
// makeSig makes a signature for the given argument and result types.
diff --git a/src/cmd/compile/internal/types2/call.go b/src/cmd/compile/internal/types2/call.go
index cf950959f9..f1727d8de1 100644
--- a/src/cmd/compile/internal/types2/call.go
+++ b/src/cmd/compile/internal/types2/call.go
@@ -58,7 +58,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
// Check the number of type arguments (got) vs number of type parameters (want).
// Note that x is a function value, not a type expression, so we don't need to
// call Underlying below.
- sig := x.typ.(*Signature)
+ sig := x.typ_.(*Signature)
got, want := len(targs), sig.TypeParams().Len()
if got > want {
// Providing too many type arguments is always an error.
@@ -99,7 +99,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
// or the result type in a return statement. Create a pseudo-expression for that operand
// that makes sense when reported in error messages from infer, below.
expr := syntax.NewName(x.Pos(), T.desc)
- args = []*operand{{mode: value, expr: expr, typ: T.sig}}
+ args = []*operand{{mode: value, expr: expr, typ_: T.sig}}
reverse = true
}
@@ -123,7 +123,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
// instantiate function signature
sig = check.instantiateSignature(x.Pos(), x.expr, sig, targs, xlist)
- x.typ = sig
+ x.typ_ = sig
x.mode = value
return nil
}
@@ -197,7 +197,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
if x.mode == invalid {
return conversion
}
- T := x.typ
+ T := x.typ_
x.mode = invalid
// We cannot convert a value to an incomplete type; make sure it's complete.
if !check.isComplete(T) {
@@ -249,7 +249,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
// If the operand type is a type parameter, all types in its type set
// must have a common underlying type, which must be a signature.
- u, err := commonUnder(x.typ, func(t, u Type) *typeError {
+ u, err := commonUnder(x.typ_, func(t, u Type) *typeError {
if _, ok := u.(*Signature); u != nil && !ok {
return typeErrorf("%s is not a function", t)
}
@@ -331,17 +331,17 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
x.expr = call
return statement
}
- x.typ = typ
+ x.typ_ = typ
default:
x.mode = value
- x.typ = sig.results
+ x.typ_ = sig.results
}
x.expr = call
check.hasCallOrRecv = true
// if type inference failed, a parameterized result must be invalidated
// (operands cannot have a parameterized type)
- if x.mode == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ) {
+ if x.mode == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ_) {
x.mode = invalid
}
@@ -380,7 +380,7 @@ func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand,
if i < len(targsList) {
if n := len(targsList[i]); n > 0 {
// x must be a partially instantiated function
- assert(n < x.typ.(*Signature).TypeParams().Len())
+ assert(n < x.typ_.(*Signature).TypeParams().Len())
}
}
}
@@ -417,11 +417,11 @@ func (check *Checker) genericExprList(elist []syntax.Expr) (resList []*operand,
// x is not a function instantiation (it may still be a generic function).
check.rawExpr(nil, &x, e, nil, true)
check.exclude(&x, 1<<novalue|1<<builtin|1<<typexpr)
- if t, ok := x.typ.(*Tuple); ok && x.mode != invalid {
+ if t, ok := x.typ_.(*Tuple); ok && x.mode != invalid {
// x is a function call returning multiple values; it cannot be generic.
resList = make([]*operand, t.Len())
for i, v := range t.vars {
- resList[i] = &operand{mode: value, expr: e, typ: v.typ}
+ resList[i] = &operand{mode: value, expr: e, typ_: v.typ}
}
} else {
// x is exactly one value (possibly invalid or uninstantiated generic function).
@@ -580,7 +580,7 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
if enableReverseTypeInference {
for i, arg := range args {
// generic arguments cannot have a defined (*Named) type - no need for underlying type below
- if asig, _ := arg.typ.(*Signature); asig != nil && asig.TypeParams().Len() > 0 {
+ if asig, _ := arg.typ_.(*Signature); asig != nil && asig.TypeParams().Len() > 0 {
// The argument type is a generic function signature. This type is
// pointer-identical with (it's copied from) the type of the generic
// function argument and thus the function object.
@@ -595,7 +595,7 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
atparams, tmp := check.renameTParams(call.Pos(), asig.TypeParams().list(), asig)
asig = tmp.(*Signature)
asig.tparams = &TypeParamList{atparams} // renameTParams doesn't touch associated type parameters
- arg.typ = asig // new type identity for the function argument
+ arg.typ_ = asig // new type identity for the function argument
tparams = append(tparams, atparams...)
// add partial list of type arguments, if any
if i < len(atargs) {
@@ -650,11 +650,11 @@ func (check *Checker) arguments(call *syntax.CallExpr, sig *Signature, targs []T
j := n
for _, i := range genericArgs {
arg := args[i]
- asig := arg.typ.(*Signature)
+ asig := arg.typ_.(*Signature)
k := j + asig.TypeParams().Len()
// targs[j:k] are the inferred type arguments for asig
- arg.typ = check.instantiateSignature(call.Pos(), arg.expr, asig, targs[j:k], nil) // TODO(gri) provide xlist if possible (partial instantiations)
- check.record(arg) // record here because we didn't use the usual expr evaluators
+ arg.typ_ = check.instantiateSignature(call.Pos(), arg.expr, asig, targs[j:k], nil) // TODO(gri) provide xlist if possible (partial instantiations)
+ check.record(arg) // record here because we didn't use the usual expr evaluators
j = k
}
}
@@ -756,27 +756,27 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
case *Const:
assert(exp.Val() != nil)
x.mode = constant_
- x.typ = exp.typ
+ x.typ_ = exp.typ
x.val = exp.val
case *TypeName:
x.mode = typexpr
- x.typ = exp.typ
+ x.typ_ = exp.typ
case *Var:
x.mode = variable
- x.typ = exp.typ
+ x.typ_ = exp.typ
if pkg.cgo && strings.HasPrefix(exp.name, "_Cvar_") {
- x.typ = x.typ.(*Pointer).base
+ x.typ_ = x.typ_.(*Pointer).base
}
case *Func:
x.mode = funcMode
- x.typ = exp.typ
+ x.typ_ = exp.typ
if pkg.cgo && strings.HasPrefix(exp.name, "_Cmacro_") {
x.mode = value
- x.typ = x.typ.(*Signature).results.vars[0].typ
+ x.typ_ = x.typ_.(*Signature).results.vars[0].typ
}
case *Builtin:
x.mode = builtin
- x.typ = exp.typ
+ x.typ_ = exp.typ
x.id = exp.id
default:
check.dump("%v: unexpected object %v", atPos(e.Sel), exp)
@@ -797,7 +797,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
}
// We cannot select on an incomplete type; make sure it's complete.
- if !check.isComplete(x.typ) {
+ if !check.isComplete(x.typ_) {
goto Error
}
@@ -818,14 +818,14 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
// Additionally, if x.typ is a pointer type, selecting implicitly dereferences the value, meaning
// its base type must also be complete.
- if p, ok := x.typ.Underlying().(*Pointer); ok && !check.isComplete(p.base) {
+ if p, ok := x.typ_.Underlying().(*Pointer); ok && !check.isComplete(p.base) {
goto Error
}
- obj, index, indirect = lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel, false)
+ obj, index, indirect = lookupFieldOrMethod(x.typ_, x.mode == variable, check.pkg, sel, false)
if obj == nil {
// Don't report another error if the underlying type was invalid (go.dev/issue/49541).
- if !isValid(x.typ.Underlying()) {
+ if !isValid(x.typ_.Underlying()) {
goto Error
}
@@ -837,19 +837,19 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
if indirect {
if x.mode == typexpr {
- check.errorf(e.Sel, InvalidMethodExpr, "invalid method expression %s.%s (needs pointer receiver (*%s).%s)", x.typ, sel, x.typ, sel)
+ check.errorf(e.Sel, InvalidMethodExpr, "invalid method expression %s.%s (needs pointer receiver (*%s).%s)", x.typ_, sel, x.typ_, sel)
} else {
- check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ)
+ check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ_)
}
goto Error
}
var why string
- if isInterfacePtr(x.typ) {
- why = check.interfacePtrError(x.typ)
+ if isInterfacePtr(x.typ_) {
+ why = check.interfacePtrError(x.typ_)
} else {
- alt, _, _ := lookupFieldOrMethod(x.typ, x.mode == variable, check.pkg, sel, true)
- why = check.lookupError(x.typ, sel, alt, false)
+ alt, _, _ := lookupFieldOrMethod(x.typ_, x.mode == variable, check.pkg, sel, true)
+ why = check.lookupError(x.typ_, sel, alt, false)
}
check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (%s)", x.expr, sel, why)
goto Error
@@ -859,18 +859,18 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
switch obj := obj.(type) {
case *Var:
if x.mode == typexpr {
- check.errorf(e.X, MissingFieldOrMethod, "operand for field selector %s must be value of type %s", sel, x.typ)
+ check.errorf(e.X, MissingFieldOrMethod, "operand for field selector %s must be value of type %s", sel, x.typ_)
goto Error
}
// field value
- check.recordSelection(e, FieldVal, x.typ, obj, index, indirect)
+ check.recordSelection(e, FieldVal, x.typ_, obj, index, indirect)
if x.mode == variable || indirect {
x.mode = variable
} else {
x.mode = value
}
- x.typ = obj.typ
+ x.typ_ = obj.typ
case *Func:
check.objDecl(obj) // ensure fully set-up signature
@@ -878,7 +878,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
if x.mode == typexpr {
// method expression
- check.recordSelection(e, MethodExpr, x.typ, obj, index, indirect)
+ check.recordSelection(e, MethodExpr, x.typ_, obj, index, indirect)
sig := obj.typ.(*Signature)
if sig.recv == nil {
@@ -906,9 +906,9 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
name = "_"
}
}
- params = append([]*Var{NewParam(sig.recv.pos, sig.recv.pkg, name, x.typ)}, params...)
+ params = append([]*Var{NewParam(sig.recv.pos, sig.recv.pkg, name, x.typ_)}, params...)
x.mode = value
- x.typ = &Signature{
+ x.typ_ = &Signature{
tparams: sig.tparams,
params: NewTuple(params...),
results: sig.results,
@@ -919,14 +919,14 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
// TODO(gri) If we needed to take into account the receiver's
// addressability, should we report the type &(x.typ) instead?
- check.recordSelection(e, MethodVal, x.typ, obj, index, indirect)
+ check.recordSelection(e, MethodVal, x.typ_, obj, index, indirect)
x.mode = value
// remove receiver
sig := *obj.typ.(*Signature)
sig.recv = nil
- x.typ = &sig
+ x.typ_ = &sig
}
default:
@@ -939,7 +939,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
Error:
x.mode = invalid
- x.typ = Typ[Invalid]
+ x.typ_ = Typ[Invalid]
x.expr = e
}
diff --git a/src/cmd/compile/internal/types2/const.go b/src/cmd/compile/internal/types2/const.go
index b68d72de4d..05190a6bc7 100644
--- a/src/cmd/compile/internal/types2/const.go
+++ b/src/cmd/compile/internal/types2/const.go
@@ -32,8 +32,8 @@ func (check *Checker) overflow(x *operand, opPos syntax.Pos) {
// their type after each constant operation.
// x.typ cannot be a type parameter (type
// parameters cannot be constant types).
- if isTyped(x.typ) {
- check.representable(x, x.typ.Underlying().(*Basic))
+ if isTyped(x.typ_) {
+ check.representable(x, x.typ_.Underlying().(*Basic))
return
}
@@ -253,7 +253,7 @@ func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, Co
assert(x.mode == constant_)
v := x.val
if !representableConst(x.val, check, typ, &v) {
- if isNumeric(x.typ) && isNumeric(typ) {
+ if isNumeric(x.typ_) && isNumeric(typ) {
// numeric conversion : error msg
//
// integer -> integer : overflows
@@ -261,7 +261,7 @@ func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, Co
// float -> integer : truncated
// float -> float : overflows
//
- if !isInteger(x.typ) && isInteger(typ) {
+ if !isInteger(x.typ_) && isInteger(typ) {
return nil, TruncatedFloat
} else {
return nil, NumericOverflow
@@ -299,8 +299,8 @@ func (check *Checker) convertUntyped(x *operand, target Type) {
x.val = val
check.updateExprVal(x.expr, val)
}
- if newType != x.typ {
- x.typ = newType
+ if newType != x.typ_ {
+ x.typ_ = newType
check.updateExprType(x.expr, newType, false)
}
}
diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go
index d0920d7ef1..cbc4fe964b 100644
--- a/src/cmd/compile/internal/types2/conversions.go
+++ b/src/cmd/compile/internal/types2/conversions.go
@@ -23,7 +23,7 @@ func (check *Checker) conversion(x *operand, T Type) {
// nothing to do
case representableConst(x.val, check, t, val):
return true
- case isInteger(x.typ) && isString(t):
+ case isInteger(x.typ_) && isString(t):
codepoint := unicode.ReplacementChar
if i, ok := constant.Uint64Val(x.val); ok && i <= unicode.MaxRune {
codepoint = rune(i)
@@ -45,7 +45,7 @@ func (check *Checker) conversion(x *operand, T Type) {
// A conversion from an integer constant to an integer type
// can only fail if there's overflow. Give a concise error.
// (go.dev/issue/63563)
- if !ok && isInteger(x.typ) && isInteger(T) {
+ if !ok && isInteger(x.typ_) && isInteger(T) {
check.errorf(x, InvalidConversion, "constant %s overflows %s", x.val, T)
x.mode = invalid
return
@@ -62,11 +62,11 @@ func (check *Checker) conversion(x *operand, T Type) {
cause = check.sprintf("%s does not contain specific types", T)
return false
}
- if isString(x.typ) && isBytesOrRunes(u) {
+ if isString(x.typ_) && isBytesOrRunes(u) {
return true
}
if !constConvertibleTo(u, nil) {
- if isInteger(x.typ) && isInteger(u) {
+ if isInteger(x.typ_) && isInteger(u) {
// see comment above on constant conversion
cause = check.sprintf("constant %s overflows %s (in %s)", x.val, u, T)
} else {
@@ -96,7 +96,7 @@ func (check *Checker) conversion(x *operand, T Type) {
// The conversion argument types are final. For untyped values the
// conversion provides the type, per the spec: "A constant may be
// given a type explicitly by a constant declaration or conversion,...".
- if isUntyped(x.typ) {
+ if isUntyped(x.typ_) {
final := T
// - For conversions to interfaces, except for untyped nil arguments
// and isTypes2, use the argument's default type.
@@ -106,17 +106,17 @@ func (check *Checker) conversion(x *operand, T Type) {
// - If !isTypes2, keep untyped nil for untyped nil arguments.
// - For constant integer to string conversions, keep the argument type.
// (See also the TODO below.)
- if isTypes2 && x.typ == Typ[UntypedNil] {
+ if isTypes2 && x.typ_ == Typ[UntypedNil] {
// ok
} else if isNonTypeParamInterface(T) || constArg && !isConstType(T) || !isTypes2 && x.isNil() {
- final = Default(x.typ) // default type of untyped nil is untyped nil
- } else if x.mode == constant_ && isInteger(x.typ) && allString(T) {
- final = x.typ
+ final = Default(x.typ_) // default type of untyped nil is untyped nil
+ } else if x.mode == constant_ && isInteger(x.typ_) && allString(T) {
+ final = x.typ_
}
check.updateExprType(x.expr, final, true)
}
- x.typ = T
+ x.typ_ = T
}
// TODO(gri) convertibleTo checks if T(x) is valid. It assumes that the type
@@ -140,7 +140,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
}
origT := T
- V := Unalias(x.typ)
+ V := Unalias(x.typ_)
T = Unalias(T)
Vu := V.Underlying()
Tu := T.Underlying()
@@ -250,7 +250,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
if V == nil {
return false // no specific types
}
- x.typ = V.typ
+ x.typ_ = V.typ
return Tp.is(func(T *term) bool {
if T == nil {
return false // no specific types
@@ -268,7 +268,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
if V == nil {
return false // no specific types
}
- x.typ = V.typ
+ x.typ_ = V.typ
if !x.convertibleTo(check, T, cause) {
errorf("cannot convert %s (in %s) to type %s", V.typ, Vp, origT)
return false
@@ -281,7 +281,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool {
return false // no specific types
}
if !x.convertibleTo(check, T.typ, cause) {
- errorf("cannot convert %s to type %s (in %s)", x.typ, T.typ, Tp)
+ errorf("cannot convert %s to type %s (in %s)", x.typ_, T.typ, Tp)
return false
}
return true
diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go
index 81aeb5ffd0..49b24b48df 100644
--- a/src/cmd/compile/internal/types2/expr.go
+++ b/src/cmd/compile/internal/types2/expr.go
@@ -72,7 +72,7 @@ func init() {
func (check *Checker) op(m opPredicates, x *operand, op syntax.Operator) bool {
if pred := m[op]; pred != nil {
- if !pred(x.typ) {
+ if !pred(x.typ_) {
check.errorf(x, UndefinedOp, invalidOp+"operator %s not defined on %s", op, x)
return false
}
@@ -144,14 +144,14 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
return
}
x.mode = value
- x.typ = &Pointer{base: x.typ}
+ x.typ_ = &Pointer{base: x.typ_}
return
case syntax.Recv:
// We cannot receive a value with an incomplete type; make sure it's complete.
if elem := check.chanElem(x, x, true); elem != nil && check.isComplete(elem) {
x.mode = commaok
- x.typ = elem
+ x.typ_ = elem
check.hasCallOrRecv = true
return
}
@@ -160,7 +160,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
case syntax.Tilde:
// Provide a better error position and message than what check.op below would do.
- if !allInteger(x.typ) {
+ if !allInteger(x.typ_) {
check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint")
x.mode = invalid
return
@@ -180,8 +180,8 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
return
}
var prec uint
- if isUnsigned(x.typ) {
- prec = uint(check.conf.sizeof(x.typ) * 8)
+ if isUnsigned(x.typ_) {
+ prec = uint(check.conf.sizeof(x.typ_) * 8)
}
x.val = constant.UnaryOp(op2tok[op], x.val, prec)
x.expr = e
@@ -197,7 +197,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
// or send to x (recv == false) operation. If the operation is not valid, chanElem
// reports an error and returns nil.
func (check *Checker) chanElem(pos poser, x *operand, recv bool) Type {
- u, err := commonUnder(x.typ, func(t, u Type) *typeError {
+ u, err := commonUnder(x.typ_, func(t, u Type) *typeError {
if u == nil {
return typeErrorf("no specific channel type")
}
@@ -220,14 +220,14 @@ func (check *Checker) chanElem(pos poser, x *operand, recv bool) Type {
cause := err.format(check)
if recv {
- if isTypeParam(x.typ) {
+ if isTypeParam(x.typ_) {
check.errorf(pos, InvalidReceive, invalidOp+"cannot receive from %s: %s", x, cause)
} else {
// In this case, only the non-channel and send-only channel error are possible.
check.errorf(pos, InvalidReceive, invalidOp+"cannot receive from %s %s", cause, x)
}
} else {
- if isTypeParam(x.typ) {
+ if isTypeParam(x.typ_) {
check.errorf(pos, InvalidSend, invalidOp+"cannot send to %s: %s", x, cause)
} else {
// In this case, only the non-channel and receive-only channel error are possible.
@@ -411,21 +411,21 @@ func (check *Checker) updateExprVal(x syntax.Expr, val constant.Value) {
// If x is a constant operand, the returned constant.Value will be the
// representation of x in this context.
func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, constant.Value, Code) {
- if x.mode == invalid || isTyped(x.typ) || !isValid(target) {
- return x.typ, nil, 0
+ if x.mode == invalid || isTyped(x.typ_) || !isValid(target) {
+ return x.typ_, nil, 0
}
// x is untyped
if isUntyped(target) {
// both x and target are untyped
- if m := maxType(x.typ, target); m != nil {
+ if m := maxType(x.typ_, target); m != nil {
return m, nil, 0
}
return nil, nil, InvalidUntypedConversion
}
if x.isNil() {
- assert(isUntyped(x.typ))
+ assert(isUntyped(x.typ_))
if hasNil(target) {
return target, nil, 0
}
@@ -445,7 +445,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
// result of comparisons (untyped bool), intermediate
// (delayed-checked) rhs operands of shifts, and as
// the value nil.
- switch x.typ.(*Basic).kind {
+ switch x.typ_.(*Basic).kind {
case UntypedBool:
if !isBoolean(target) {
return nil, nil, InvalidUntypedConversion
@@ -483,7 +483,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
if !u.Empty() {
return nil, nil, InvalidUntypedConversion // cannot assign untyped values to non-empty interfaces
}
- return Default(x.typ), nil, 0 // default type for nil is nil
+ return Default(x.typ_), nil, 0 // default type for nil is nil
default:
return nil, nil, InvalidUntypedConversion
}
@@ -493,7 +493,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
// If switchCase is true, the operator op is ignored.
func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase bool) {
// Avoid spurious errors if any of the operands has an invalid type (go.dev/issue/54405).
- if !isValid(x.typ) || !isValid(y.typ) {
+ if !isValid(x.typ_) || !isValid(y.typ_) {
x.mode = invalid
return
}
@@ -508,16 +508,16 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase b
// spec: "In any comparison, the first operand must be assignable
// to the type of the second operand, or vice versa."
code := MismatchedTypes
- ok, _ := x.assignableTo(check, y.typ, nil)
+ ok, _ := x.assignableTo(check, y.typ_, nil)
if !ok {
- ok, _ = y.assignableTo(check, x.typ, nil)
+ ok, _ = y.assignableTo(check, x.typ_, nil)
}
if !ok {
// Report the error on the 2nd operand since we only
// know after seeing the 2nd operand whether we have
// a type mismatch.
errOp = y
- cause = check.sprintf("mismatched types %s and %s", x.typ, y.typ)
+ cause = check.sprintf("mismatched types %s and %s", x.typ_, y.typ_)
goto Error
}
@@ -529,9 +529,9 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase b
switch {
case x.isNil() || y.isNil():
// Comparison against nil requires that the other operand type has nil.
- typ := x.typ
+ typ := x.typ_
if x.isNil() {
- typ = y.typ
+ typ = y.typ_
}
if !hasNil(typ) {
// This case should only be possible for "nil == nil".
@@ -542,24 +542,24 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase b
goto Error
}
- case !Comparable(x.typ):
+ case !Comparable(x.typ_):
errOp = x
- cause = check.incomparableCause(x.typ)
+ cause = check.incomparableCause(x.typ_)
goto Error
- case !Comparable(y.typ):
+ case !Comparable(y.typ_):
errOp = y
- cause = check.incomparableCause(y.typ)
+ cause = check.incomparableCause(y.typ_)
goto Error
}
case syntax.Lss, syntax.Leq, syntax.Gtr, syntax.Geq:
// spec: The ordering operators <, <=, >, and >= apply to operands that are ordered."
switch {
- case !allOrdered(x.typ):
+ case !allOrdered(x.typ_):
errOp = x
goto Error
- case !allOrdered(y.typ):
+ case !allOrdered(y.typ_):
errOp = y
goto Error
}
@@ -579,29 +579,29 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase b
// time will be materialized. Update the expression trees.
// If the current types are untyped, the materialized type
// is the respective default type.
- check.updateExprType(x.expr, Default(x.typ), true)
- check.updateExprType(y.expr, Default(y.typ), true)
+ check.updateExprType(x.expr, Default(x.typ_), true)
+ check.updateExprType(y.expr, Default(y.typ_), true)
}
// spec: "Comparison operators compare two operands and yield
// an untyped boolean value."
- x.typ = Typ[UntypedBool]
+ x.typ_ = Typ[UntypedBool]
return
Error:
// We have an offending operand errOp and possibly an error cause.
if cause == "" {
- if isTypeParam(x.typ) || isTypeParam(y.typ) {
+ if isTypeParam(x.typ_) || isTypeParam(y.typ_) {
// TODO(gri) should report the specific type causing the problem, if any
- if !isTypeParam(x.typ) {
+ if !isTypeParam(x.typ_) {
errOp = y
}
- cause = check.sprintf("type parameter %s cannot use operator %s", errOp.typ, op)
+ cause = check.sprintf("type parameter %s cannot use operator %s", errOp.typ_, op)
} else {
// catch-all: neither x nor y is a type parameter
- what := compositeKind(errOp.typ)
+ what := compositeKind(errOp.typ_)
if what == "" {
- what = check.sprintf("%s", errOp.typ)
+ what = check.sprintf("%s", errOp.typ_)
}
cause = check.sprintf("operator %s not defined on %s", op, what)
}
@@ -634,7 +634,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
xval = constant.ToInt(x.val)
}
- if allInteger(x.typ) || isUntyped(x.typ) && xval != nil && xval.Kind() == constant.Int {
+ if allInteger(x.typ_) || isUntyped(x.typ_) && xval != nil && xval.Kind() == constant.Int {
// The lhs is of integer type or an untyped constant representable
// as an integer. Nothing to do.
} else {
@@ -659,7 +659,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
return
}
- if isUntyped(y.typ) {
+ if isUntyped(y.typ_) {
// Caution: Check for representability here, rather than in the switch
// below, because isInteger includes untyped integers (was bug go.dev/issue/43697).
check.representable(y, Typ[Uint])
@@ -671,12 +671,12 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
} else {
// Check that RHS is otherwise at least of integer type.
switch {
- case allInteger(y.typ):
- if !allUnsigned(y.typ) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) {
+ case allInteger(y.typ_):
+ if !allUnsigned(y.typ_) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) {
x.mode = invalid
return
}
- case isUntyped(y.typ):
+ case isUntyped(y.typ_):
// This is incorrect, but preserves pre-existing behavior.
// See also go.dev/issue/47410.
check.convertUntyped(y, Typ[Uint])
@@ -697,8 +697,8 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown {
x.val = constant.MakeUnknown()
// ensure the correct type - see comment below
- if !isInteger(x.typ) {
- x.typ = Typ[UntypedInt]
+ if !isInteger(x.typ_) {
+ x.typ_ = Typ[UntypedInt]
}
return
}
@@ -714,8 +714,8 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
// (e.g., 2.0, an untyped float) - this can only happen for untyped
// non-integer numeric constants. Correct the type so that the shift
// result is of integer type.
- if !isInteger(x.typ) {
- x.typ = Typ[UntypedInt]
+ if !isInteger(x.typ_) {
+ x.typ_ = Typ[UntypedInt]
}
// x is a constant so xval != nil and it must be of Int kind.
x.val = constant.Shift(xval, op2tok[op], uint(s))
@@ -725,7 +725,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
}
// non-constant shift with constant lhs
- if isUntyped(x.typ) {
+ if isUntyped(x.typ_) {
// spec: "If the left operand of a non-constant shift
// expression is an untyped constant, the type of the
// constant is what it would be if the shift expression
@@ -756,7 +756,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
}
// non-constant shift - lhs must be an integer
- if !allInteger(x.typ) {
+ if !allInteger(x.typ_) {
check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
x.mode = invalid
return
@@ -818,14 +818,14 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
return
}
- if !Identical(x.typ, y.typ) {
+ if !Identical(x.typ_, y.typ_) {
// only report an error if we have valid types
// (otherwise we had an error reported elsewhere already)
- if isValid(x.typ) && isValid(y.typ) {
+ if isValid(x.typ_) && isValid(y.typ_) {
if e != nil {
- check.errorf(x, MismatchedTypes, invalidOp+"%s (mismatched types %s and %s)", e, x.typ, y.typ)
+ check.errorf(x, MismatchedTypes, invalidOp+"%s (mismatched types %s and %s)", e, x.typ_, y.typ_)
} else {
- check.errorf(x, MismatchedTypes, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ, y.typ)
+ check.errorf(x, MismatchedTypes, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ_, y.typ_)
}
}
x.mode = invalid
@@ -839,14 +839,14 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
if op == syntax.Div || op == syntax.Rem {
// check for zero divisor
- if (x.mode == constant_ || allInteger(x.typ)) && y.mode == constant_ && constant.Sign(y.val) == 0 {
+ if (x.mode == constant_ || allInteger(x.typ_)) && y.mode == constant_ && constant.Sign(y.val) == 0 {
check.error(&y, DivByZero, invalidOp+"division by zero")
x.mode = invalid
return
}
// check for divisor underflow in complex division (see go.dev/issue/20227)
- if x.mode == constant_ && y.mode == constant_ && isComplex(x.typ) {
+ if x.mode == constant_ && y.mode == constant_ && isComplex(x.typ_) {
re, im := constant.Real(y.val), constant.Imag(y.val)
re2, im2 := constant.BinaryOp(re, token.MUL, re), constant.BinaryOp(im, token.MUL, im)
if constant.Sign(re2) == 0 && constant.Sign(im2) == 0 {
@@ -866,7 +866,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
}
// force integer division for integer operands
tok := op2tok[op]
- if op == syntax.Div && isInteger(x.typ) {
+ if op == syntax.Div && isInteger(x.typ_) {
tok = token.QUO_ASSIGN
}
x.val = constant.BinaryOp(x.val, tok, y.val)
@@ -893,49 +893,49 @@ func (check *Checker) matchTypes(x, y *operand) {
// not compatible, we report a type mismatch error.
mayConvert := func(x, y *operand) bool {
// If both operands are typed, there's no need for an implicit conversion.
- if isTyped(x.typ) && isTyped(y.typ) {
+ if isTyped(x.typ_) && isTyped(y.typ_) {
return false
}
// A numeric type can only convert to another numeric type.
- if allNumeric(x.typ) != allNumeric(y.typ) {
+ if allNumeric(x.typ_) != allNumeric(y.typ_) {
return false
}
// An untyped operand may convert to its default type when paired with an empty interface
// TODO(gri) This should only matter for comparisons (the only binary operation that is
// valid with interfaces), but in that case the assignability check should take
// care of the conversion. Verify and possibly eliminate this extra test.
- if isNonTypeParamInterface(x.typ) || isNonTypeParamInterface(y.typ) {
+ if isNonTypeParamInterface(x.typ_) || isNonTypeParamInterface(y.typ_) {
return true
}
// A boolean type can only convert to another boolean type.
- if allBoolean(x.typ) != allBoolean(y.typ) {
+ if allBoolean(x.typ_) != allBoolean(y.typ_) {
return false
}
// A string type can only convert to another string type.
- if allString(x.typ) != allString(y.typ) {
+ if allString(x.typ_) != allString(y.typ_) {
return false
}
// Untyped nil can only convert to a type that has a nil.
if x.isNil() {
- return hasNil(y.typ)
+ return hasNil(y.typ_)
}
if y.isNil() {
- return hasNil(x.typ)
+ return hasNil(x.typ_)
}
// An untyped operand cannot convert to a pointer.
// TODO(gri) generalize to type parameters
- if isPointer(x.typ) || isPointer(y.typ) {
+ if isPointer(x.typ_) || isPointer(y.typ_) {
return false
}
return true
}
if mayConvert(x, y) {
- check.convertUntyped(x, y.typ)
+ check.convertUntyped(x, y.typ_)
if x.mode == invalid {
return
}
- check.convertUntyped(y, x.typ)
+ check.convertUntyped(y, x.typ_)
if y.mode == invalid {
x.mode = invalid
return
@@ -1007,7 +1007,7 @@ func (check *Checker) nonGeneric(T *target, x *operand) {
return
}
var what string
- switch t := x.typ.(type) {
+ switch t := x.typ_.(type) {
case *Alias, *Named:
if isGeneric(t) {
what = "type"
@@ -1024,7 +1024,7 @@ func (check *Checker) nonGeneric(T *target, x *operand) {
if what != "" {
check.errorf(x.expr, WrongTypeArgCount, "cannot use generic %s %s without instantiation", what, x.expr)
x.mode = invalid
- x.typ = Typ[Invalid]
+ x.typ_ = Typ[Invalid]
}
}
@@ -1035,7 +1035,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
// make sure x has a valid state in case of bailout
// (was go.dev/issue/5770)
x.mode = invalid
- x.typ = Typ[Invalid]
+ x.typ_ = Typ[Invalid]
switch e := e.(type) {
case nil:
@@ -1109,11 +1109,11 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
check.error(e, InvalidSyntaxTree, "invalid use of AssertExpr")
goto Error
}
- if isTypeParam(x.typ) {
+ if isTypeParam(x.typ_) {
check.errorf(x, InvalidAssert, invalidOp+"cannot use type assertion on type parameter value %s", x)
goto Error
}
- if _, ok := x.typ.Underlying().(*Interface); !ok {
+ if _, ok := x.typ_.Underlying().(*Interface); !ok {
check.errorf(x, InvalidAssert, invalidOp+"%s is not an interface", x)
goto Error
}
@@ -1127,7 +1127,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
}
check.typeAssertion(e, x, T, false)
x.mode = commaok
- x.typ = T
+ x.typ_ = T
case *syntax.TypeSwitchGuard:
// x.(type) expressions are handled explicitly in type switches
@@ -1173,11 +1173,11 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
case invalid:
goto Error
case typexpr:
- check.validVarType(e.X, x.typ)
- x.typ = &Pointer{base: x.typ}
+ check.validVarType(e.X, x.typ_)
+ x.typ_ = &Pointer{base: x.typ_}
default:
var base Type
- if !underIs(x.typ, func(u Type) bool {
+ if !underIs(x.typ_, func(u Type) bool {
p, _ := u.(*Pointer)
if p == nil {
check.errorf(x, InvalidIndirection, invalidOp+"cannot indirect %s", x)
@@ -1197,7 +1197,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
goto Error
}
x.mode = variable
- x.typ = base
+ x.typ_ = base
}
break
}
@@ -1227,7 +1227,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
case *syntax.ArrayType, *syntax.SliceType, *syntax.StructType, *syntax.FuncType,
*syntax.InterfaceType, *syntax.MapType, *syntax.ChanType:
x.mode = typexpr
- x.typ = check.typ(e)
+ x.typ_ = check.typ(e)
// Note: rawExpr (caller of exprInternal) will call check.recordTypeAndValue
// even though check.typ has already called it. This is fine as both
// times the same expression and type are recorded. It is also not a
@@ -1293,7 +1293,7 @@ func keyVal(x constant.Value) any {
// typeAssertion checks x.(T). The type of x must be an interface.
func (check *Checker) typeAssertion(e syntax.Expr, x *operand, T Type, typeSwitch bool) {
var cause string
- if check.assertableTo(x.typ, T, &cause) {
+ if check.assertableTo(x.typ_, T, &cause) {
return // success
}
@@ -1302,7 +1302,7 @@ func (check *Checker) typeAssertion(e syntax.Expr, x *operand, T Type, typeSwitc
return
}
- check.errorf(e, ImpossibleAssert, "impossible type assertion: %s\n\t%s does not implement %s %s", e, T, x.typ, cause)
+ check.errorf(e, ImpossibleAssert, "impossible type assertion: %s\n\t%s does not implement %s %s", e, T, x.typ_, cause)
}
// expr typechecks expression e and initializes x with the expression value.
@@ -1333,11 +1333,11 @@ func (check *Checker) multiExpr(e syntax.Expr, allowCommaOk bool) (list []*opera
check.rawExpr(nil, &x, e, nil, false)
check.exclude(&x, 1<<novalue|1<<builtin|1<<typexpr)
- if t, ok := x.typ.(*Tuple); ok && x.mode != invalid {
+ if t, ok := x.typ_.(*Tuple); ok && x.mode != invalid {
// multiple values
list = make([]*operand, t.Len())
for i, v := range t.vars {
- list[i] = &operand{mode: value, expr: e, typ: v.typ}
+ list[i] = &operand{mode: value, expr: e, typ_: v.typ}
}
return
}
@@ -1345,9 +1345,9 @@ func (check *Checker) multiExpr(e syntax.Expr, allowCommaOk bool) (list []*opera
// exactly one (possibly invalid or comma-ok) value
list = []*operand{&x}
if allowCommaOk && (x.mode == mapindex || x.mode == commaok || x.mode == commaerr) {
- x2 := &operand{mode: value, expr: e, typ: Typ[UntypedBool]}
+ x2 := &operand{mode: value, expr: e, typ_: Typ[UntypedBool]}
if x.mode == commaerr {
- x2.typ = universeError
+ x2.typ_ = universeError
}
list = append(list, x2)
commaOk = true
@@ -1408,7 +1408,7 @@ func (check *Checker) exclude(x *operand, modeset uint) {
func (check *Checker) singleValue(x *operand) {
if x.mode == value {
// tuple types are never named - no need for underlying type below
- if t, ok := x.typ.(*Tuple); ok {
+ if t, ok := x.typ_.(*Tuple); ok {
assert(t.Len() != 1)
check.errorf(x, TooManyValues, "multiple-value %s in single-value context", x)
x.mode = invalid
diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go
index 5b52cea837..6c659a599d 100644
--- a/src/cmd/compile/internal/types2/index.go
+++ b/src/cmd/compile/internal/types2/index.go
@@ -28,14 +28,14 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
// type instantiation
x.mode = invalid
// TODO(gri) here we re-evaluate e.X - try to avoid this
- x.typ = check.varType(e)
- if isValid(x.typ) {
+ x.typ_ = check.varType(e)
+ if isValid(x.typ_) {
x.mode = typexpr
}
return false
case value:
- if sig, _ := x.typ.Underlying().(*Signature); sig != nil && sig.TypeParams().Len() > 0 {
+ if sig, _ := x.typ_.Underlying().(*Signature); sig != nil && sig.TypeParams().Len() > 0 {
// function instantiation
return true
}
@@ -48,11 +48,11 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
}
// We cannot index on an incomplete type; make sure it's complete.
- if !check.isComplete(x.typ) {
+ if !check.isComplete(x.typ_) {
x.mode = invalid
return false
}
- switch typ := x.typ.Underlying().(type) {
+ switch typ := x.typ_.Underlying().(type) {
case *Pointer:
// Additionally, if x.typ is a pointer to an array type, indexing implicitly dereferences the value, meaning
// its base type must also be complete.
@@ -72,7 +72,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
// ordinary index expression
valid := false
length := int64(-1) // valid if >= 0
- switch typ := x.typ.Underlying().(type) {
+ switch typ := x.typ_.Underlying().(type) {
case *Basic:
if isString(typ) {
valid = true
@@ -83,7 +83,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
// (not a constant) even if the string and the
// index are constant
x.mode = value
- x.typ = universeByte // use 'byte' name
+ x.typ_ = universeByte // use 'byte' name
}
case *Array:
@@ -92,20 +92,20 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
if x.mode != variable {
x.mode = value
}
- x.typ = typ.elem
+ x.typ_ = typ.elem
case *Pointer:
if typ, _ := typ.base.Underlying().(*Array); typ != nil {
valid = true
length = typ.len
x.mode = variable
- x.typ = typ.elem
+ x.typ_ = typ.elem
}
case *Slice:
valid = true
x.mode = variable
- x.typ = typ.elem
+ x.typ_ = typ.elem
case *Map:
index := check.singleIndex(e)
@@ -118,19 +118,19 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
check.assignment(&key, typ.key, "map index")
// ok to continue even if indexing failed - map element type is known
x.mode = mapindex
- x.typ = typ.elem
+ x.typ_ = typ.elem
x.expr = e
return false
case *Interface:
- if !isTypeParam(x.typ) {
+ if !isTypeParam(x.typ_) {
break
}
// TODO(gri) report detailed failure cause for better error messages
var key, elem Type // key != nil: we must have all maps
mode := variable // non-maps result mode
// TODO(gri) factor out closure and use it for non-typeparam cases as well
- if underIs(x.typ, func(u Type) bool {
+ if underIs(x.typ_, func(u Type) bool {
l := int64(-1) // valid if >= 0
var k, e Type // k is only set for maps
switch t := u.(type) {
@@ -192,7 +192,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
check.assignment(&k, key, "map index")
// ok to continue even if indexing failed - map element type is known
x.mode = mapindex
- x.typ = elem
+ x.typ_ = elem
x.expr = e
return false
}
@@ -200,7 +200,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
// no maps
valid = true
x.mode = mode
- x.typ = elem
+ x.typ_ = elem
}
}
@@ -220,8 +220,8 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
// In pathological (invalid) cases (e.g.: type T1 [][[]T1{}[0][0]]T0)
// the element type may be accessed before it's set. Make sure we have
// a valid type.
- if x.typ == nil {
- x.typ = Typ[Invalid]
+ if x.typ_ == nil {
+ x.typ_ = Typ[Invalid]
}
check.index(index, length)
@@ -238,9 +238,9 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
// determine common underlying type cu
var ct, cu Type // type and respective common underlying type
var hasString bool
- for t, u := range typeset(x.typ) {
+ for t, u := range typeset(x.typ_) {
if u == nil {
- check.errorf(x, NonSliceableOperand, "cannot slice %s: no specific type in %s", x, x.typ)
+ check.errorf(x, NonSliceableOperand, "cannot slice %s: no specific type in %s", x, x.typ_)
cu = nil
break
}
@@ -268,15 +268,15 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
// If we saw a string, proceed with string type,
// but don't go from untyped string to string.
cu = Typ[String]
- if !isTypeParam(x.typ) {
- cu = x.typ.Underlying() // untyped string remains untyped
+ if !isTypeParam(x.typ_) {
+ cu = x.typ_.Underlying() // untyped string remains untyped
}
}
// Note that we don't permit slice expressions where x is a type expression, so we don't check for that here.
// However, if x.typ is a pointer to an array type, slicing implicitly dereferences the value, meaning
// its base type must also be complete.
- if p, ok := x.typ.Underlying().(*Pointer); ok && !check.isComplete(p.base) {
+ if p, ok := x.typ_.Underlying().(*Pointer); ok && !check.isComplete(p.base) {
x.mode = invalid
return
}
@@ -306,8 +306,8 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
}
// spec: "For untyped string operands the result
// is a non-constant value of type string."
- if isUntyped(x.typ) {
- x.typ = Typ[String]
+ if isUntyped(x.typ_) {
+ x.typ_ = Typ[String]
}
}
@@ -319,13 +319,13 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
x.mode = invalid
return
}
- x.typ = &Slice{elem: u.elem}
+ x.typ_ = &Slice{elem: u.elem}
case *Pointer:
if u, _ := u.base.Underlying().(*Array); u != nil {
valid = true
length = u.len
- x.typ = &Slice{elem: u.elem}
+ x.typ_ = &Slice{elem: u.elem}
}
case *Slice:
@@ -428,7 +428,7 @@ func (check *Checker) index(index syntax.Expr, max int64) (typ Type, val int64)
}
if x.mode != constant_ {
- return x.typ, -1
+ return x.typ_, -1
}
if x.val.Kind() == constant.Unknown {
@@ -443,7 +443,7 @@ func (check *Checker) index(index syntax.Expr, max int64) (typ Type, val int64)
}
// 0 <= v [ && v < max ]
- return x.typ, v
+ return x.typ_, v
}
// isValidIndex checks whether operand x satisfies the criteria for integer
@@ -462,7 +462,7 @@ func (check *Checker) isValidIndex(x *operand, code Code, what string, allowNega
}
// spec: "the index x must be of integer type or an untyped constant"
- if !allInteger(x.typ) {
+ if !allInteger(x.typ_) {
check.errorf(x, code, invalidArg+"%s %s must be integer", what, x)
return false
}
diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go
index 996f6a5109..5ba3583916 100644
--- a/src/cmd/compile/internal/types2/infer.go
+++ b/src/cmd/compile/internal/types2/infer.go
@@ -170,12 +170,12 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
continue
}
par := params.At(i)
- if isParameterized(tparams, par.typ) || isParameterized(tparams, arg.typ) {
+ if isParameterized(tparams, par.typ) || isParameterized(tparams, arg.typ_) {
// Function parameters are always typed. Arguments may be untyped.
// Collect the indices of untyped arguments and handle them later.
- if isTyped(arg.typ) {
- if !u.unify(par.typ, arg.typ, assign) {
- errorf(par.typ, arg.typ, arg)
+ if isTyped(arg.typ_) {
+ if !u.unify(par.typ, arg.typ_, assign) {
+ errorf(par.typ, arg.typ_, arg)
return nil
}
} else if _, ok := par.typ.(*TypeParam); ok && !arg.isNil() {
@@ -337,11 +337,11 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
}
max := maxUntyped[tpar]
if max == nil {
- max = arg.typ
+ max = arg.typ_
} else {
- m := maxType(max, arg.typ)
+ m := maxType(max, arg.typ_)
if m == nil {
- err.addf(arg, "mismatched types %s and %s (cannot infer %s)", max, arg.typ, tpar)
+ err.addf(arg, "mismatched types %s and %s (cannot infer %s)", max, arg.typ_, tpar)
return nil
}
max = m
diff --git a/src/cmd/compile/internal/types2/literals.go b/src/cmd/compile/internal/types2/literals.go
index 6817231a76..893f37caa5 100644
--- a/src/cmd/compile/internal/types2/literals.go
+++ b/src/cmd/compile/internal/types2/literals.go
@@ -97,7 +97,7 @@ func (check *Checker) funcLit(x *operand, e *syntax.FuncLit) {
}).describef(e, "func literal")
}
x.mode = value
- x.typ = sig
+ x.typ_ = sig
} else {
check.errorf(e, InvalidSyntaxTree, "invalid function literal %v", e)
x.mode = invalid
@@ -269,12 +269,12 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
xkey := keyVal(x.val)
if keyIsInterface {
for _, vtyp := range visited[xkey] {
- if Identical(vtyp, x.typ) {
+ if Identical(vtyp, x.typ_) {
duplicate = true
break
}
}
- visited[xkey] = append(visited[xkey], x.typ)
+ visited[xkey] = append(visited[xkey], x.typ_)
} else {
_, duplicate = visited[xkey]
visited[xkey] = nil
@@ -317,7 +317,7 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
}
x.mode = value
- x.typ = typ
+ x.typ_ = typ
}
// indexedElts checks the elements (elts) of an array or slice composite literal
diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go
index cd9e9f3575..884b4edb81 100644
--- a/src/cmd/compile/internal/types2/operand.go
+++ b/src/cmd/compile/internal/types2/operand.go
@@ -55,7 +55,7 @@ var operandModeString = [...]string{
type operand struct {
mode operandMode
expr syntax.Expr
- typ Type
+ typ_ Type
val constant.Value
id builtinId
}
@@ -110,17 +110,17 @@ func operandString(x *operand, qf Qualifier) string {
// special-case nil
if isTypes2 {
if x.mode == nilvalue {
- switch x.typ {
+ switch x.typ_ {
case nil, Typ[Invalid]:
return "nil (with invalid type)"
case Typ[UntypedNil]:
return "nil"
default:
- return fmt.Sprintf("nil (of type %s)", TypeString(x.typ, qf))
+ return fmt.Sprintf("nil (of type %s)", TypeString(x.typ_, qf))
}
}
} else { // go/types
- if x.mode == value && x.typ == Typ[UntypedNil] {
+ if x.mode == value && x.typ_ == Typ[UntypedNil] {
return "nil"
}
}
@@ -135,7 +135,7 @@ func operandString(x *operand, qf Qualifier) string {
case builtin:
expr = predeclaredFuncs[x.id].name
case typexpr:
- expr = TypeString(x.typ, qf)
+ expr = TypeString(x.typ_, qf)
case constant_:
expr = x.val.String()
}
@@ -154,9 +154,9 @@ func operandString(x *operand, qf Qualifier) string {
// no type
default:
// should have a type, but be cautious (don't crash during printing)
- if x.typ != nil {
- if isUntyped(x.typ) {
- buf.WriteString(x.typ.(*Basic).name)
+ if x.typ_ != nil {
+ if isUntyped(x.typ_) {
+ buf.WriteString(x.typ_.(*Basic).name)
buf.WriteByte(' ')
break
}
@@ -177,9 +177,9 @@ func operandString(x *operand, qf Qualifier) string {
// <typ>
if hasType {
- if isValid(x.typ) {
+ if isValid(x.typ_) {
var desc string
- if isGeneric(x.typ) {
+ if isGeneric(x.typ_) {
desc = "generic "
}
@@ -187,14 +187,14 @@ func operandString(x *operand, qf Qualifier) string {
// If the type is a renamed basic type, describe the basic type,
// as in "int32 type MyInt" for a *Named type MyInt.
// If it is a type parameter, describe the constraint instead.
- tpar, _ := Unalias(x.typ).(*TypeParam)
+ tpar, _ := Unalias(x.typ_).(*TypeParam)
if tpar == nil {
- switch x.typ.(type) {
+ switch x.typ_.(type) {
case *Alias, *Named:
- what := compositeKind(x.typ)
+ what := compositeKind(x.typ_)
if what == "" {
// x.typ must be basic type
- what = x.typ.Underlying().(*Basic).name
+ what = x.typ_.Underlying().(*Basic).name
}
desc += what + " "
}
@@ -202,7 +202,7 @@ func operandString(x *operand, qf Qualifier) string {
// desc is "" or has a trailing space at the end
buf.WriteString(" of " + desc + "type ")
- WriteType(&buf, x.typ, qf)
+ WriteType(&buf, x.typ_, qf)
if tpar != nil {
buf.WriteString(" constrained by ")
@@ -282,11 +282,11 @@ func (x *operand) setConst(k syntax.LitKind, lit string) {
val := makeFromLiteral(lit, k)
if val.Kind() == constant.Unknown {
x.mode = invalid
- x.typ = Typ[Invalid]
+ x.typ_ = Typ[Invalid]
return
}
x.mode = constant_
- x.typ = Typ[kind]
+ x.typ_ = Typ[kind]
x.val = val
}
@@ -295,7 +295,7 @@ func (x *operand) isNil() bool {
if isTypes2 {
return x.mode == nilvalue
} else { // go/types
- return x.mode == value && x.typ == Typ[UntypedNil]
+ return x.mode == value && x.typ_ == Typ[UntypedNil]
}
}
@@ -311,7 +311,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod
}
origT := T
- V := Unalias(x.typ)
+ V := Unalias(x.typ_)
T = Unalias(T)
// x's type is identical to T
@@ -416,7 +416,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod
}
ok, code = x.assignableTo(check, T.typ, cause)
if !ok {
- errorf("cannot assign %s to %s (in %s)", x.typ, T.typ, Tp)
+ errorf("cannot assign %s to %s (in %s)", x.typ_, T.typ, Tp)
return false
}
return true
@@ -435,7 +435,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod
if V == nil {
return false // no specific types
}
- x.typ = V.typ
+ x.typ_ = V.typ
ok, code = x.assignableTo(check, T, cause)
if !ok {
errorf("cannot assign %s (in %s) to %s", V.typ, Vp, origT)
diff --git a/src/cmd/compile/internal/types2/range.go b/src/cmd/compile/internal/types2/range.go
index 899f5c0991..37a701a0fb 100644
--- a/src/cmd/compile/internal/types2/range.go
+++ b/src/cmd/compile/internal/types2/range.go
@@ -35,7 +35,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
check.expr(nil, &x, rangeVar)
if isTypes2 && x.mode != invalid && sValue == nil && !check.hasCallOrRecv {
- if t, ok := arrayPtrDeref(x.typ.Underlying()).(*Array); ok {
+ if t, ok := arrayPtrDeref(x.typ_.Underlying()).(*Array); ok {
for {
// Put constant info on the thing inside parentheses.
// That's where (*../noder/writer).expr expects it.
@@ -52,7 +52,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
check.record(&operand{
mode: constant_,
expr: rangeVar,
- typ: Typ[Int],
+ typ_: Typ[Int],
val: constant.MakeInt64(t.len),
id: x.id,
})
@@ -62,7 +62,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
// determine key/value types
var key, val Type
if x.mode != invalid {
- k, v, cause, ok := rangeKeyVal(check, x.typ, func(v goVersion) bool {
+ k, v, cause, ok := rangeKeyVal(check, x.typ_, func(v goVersion) bool {
return check.allowVersion(v)
})
switch {
@@ -92,7 +92,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
lhs := [2]syntax.Expr{sKey, sValue} // sKey, sValue may be nil
rhs := [2]Type{key, val} // key, val may be nil
- rangeOverInt := isInteger(x.typ)
+ rangeOverInt := isInteger(x.typ_)
if isDef {
// short variable declaration
@@ -135,7 +135,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
var y operand
y.mode = value
y.expr = lhs // we don't have a better rhs expression to use here
- y.typ = typ
+ y.typ_ = typ
check.initVar(obj, &y, "assignment") // error is on variable, use "assignment" not "range clause"
}
assert(obj.typ != nil)
@@ -169,14 +169,14 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
// If the assignment succeeded, if x was untyped before, it now
// has a type inferred via the assignment. It must be an integer.
// (go.dev/issues/67027)
- if x.mode != invalid && !isInteger(x.typ) {
- check.softErrorf(lhs, InvalidRangeExpr, "cannot use iteration variable of type %s", x.typ)
+ if x.mode != invalid && !isInteger(x.typ_) {
+ check.softErrorf(lhs, InvalidRangeExpr, "cannot use iteration variable of type %s", x.typ_)
}
} else {
var y operand
y.mode = value
y.expr = lhs // we don't have a better rhs expression to use here
- y.typ = typ
+ y.typ_ = typ
check.assignVar(lhs, nil, &y, "assignment") // error is on variable, use "assignment" not "range clause"
}
}
diff --git a/src/cmd/compile/internal/types2/recording.go b/src/cmd/compile/internal/types2/recording.go
index 2c83dd2db9..5a6b295418 100644
--- a/src/cmd/compile/internal/types2/recording.go
+++ b/src/cmd/compile/internal/types2/recording.go
@@ -23,10 +23,10 @@ func (check *Checker) record(x *operand) {
case novalue:
typ = (*Tuple)(nil)
case constant_:
- typ = x.typ
+ typ = x.typ_
val = x.val
default:
- typ = x.typ
+ typ = x.typ_
}
assert(x.expr != nil && typ != nil)
@@ -97,7 +97,7 @@ func (check *Checker) recordCommaOkTypes(x syntax.Expr, a []*operand) {
if a[0].mode == invalid {
return
}
- t0, t1 := a[0].typ, a[1].typ
+ t0, t1 := a[0].typ_, a[1].typ_
assert(isTyped(t0) && isTyped(t1) && (allBoolean(t1) || t1 == universeError))
if m := check.Types; m != nil {
for {
diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go
index 47ca4d90ec..732f8a9b74 100644
--- a/src/cmd/compile/internal/types2/stmt.go
+++ b/src/cmd/compile/internal/types2/stmt.go
@@ -241,7 +241,7 @@ L:
if x.mode == invalid || v.mode == invalid {
continue L
}
- check.convertUntyped(&v, x.typ)
+ check.convertUntyped(&v, x.typ_)
if v.mode == invalid {
continue L
}
@@ -259,7 +259,7 @@ L:
// look for duplicate types for a given value
// (quadratic algorithm, but these lists tend to be very short)
for _, vt := range seen[val] {
- if Identical(v.typ, vt.typ) {
+ if Identical(v.typ_, vt.typ) {
err := check.newError(DuplicateCase)
err.addf(&v, "duplicate case %s in expression switch", &v)
err.addf(vt.pos, "previous case")
@@ -267,7 +267,7 @@ L:
continue L
}
}
- seen[val] = append(seen[val], valueType{v.Pos(), v.typ})
+ seen[val] = append(seen[val], valueType{v.Pos(), v.typ_})
}
}
}
@@ -345,7 +345,7 @@ L:
if len(types) != 1 || T == nil {
T = Typ[Invalid]
if x != nil {
- T = x.typ
+ T = x.typ_
}
}
@@ -398,7 +398,7 @@ L:
if len(types) != 1 || T == nil {
T = Typ[Invalid]
if x != nil {
- T = x.typ
+ T = x.typ_
}
}
@@ -480,8 +480,8 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) {
if x.mode == invalid {
return
}
- if !allNumeric(x.typ) {
- check.errorf(s.Lhs, NonNumericIncDec, invalidOp+"%s%s%s (non-numeric type %s)", s.Lhs, s.Op, s.Op, x.typ)
+ if !allNumeric(x.typ_) {
+ check.errorf(s.Lhs, NonNumericIncDec, invalidOp+"%s%s%s (non-numeric type %s)", s.Lhs, s.Op, s.Op, x.typ_)
return
}
check.assignVar(s.Lhs, nil, &x, "assignment")
@@ -592,7 +592,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) {
check.simpleStmt(s.Init)
var x operand
check.expr(nil, &x, s.Cond)
- if x.mode != invalid && !allBoolean(x.typ) {
+ if x.mode != invalid && !allBoolean(x.typ_) {
check.error(s.Cond, InvalidCond, "non-boolean condition in if statement")
}
check.stmt(inner, s.Then)
@@ -694,7 +694,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) {
if s.Cond != nil {
var x operand
check.expr(nil, &x, s.Cond)
- if x.mode != invalid && !allBoolean(x.typ) {
+ if x.mode != invalid && !allBoolean(x.typ_) {
check.error(s.Cond, InvalidCond, "non-boolean condition in for statement")
}
}
@@ -721,15 +721,15 @@ func (check *Checker) switchStmt(inner stmtContext, s *syntax.SwitchStmt) {
// By checking assignment of x to an invisible temporary
// (as a compiler would), we get all the relevant checks.
check.assignment(&x, nil, "switch expression")
- if x.mode != invalid && !Comparable(x.typ) && !hasNil(x.typ) {
- check.errorf(&x, InvalidExprSwitch, "cannot switch on %s (%s is not comparable)", &x, x.typ)
+ if x.mode != invalid && !Comparable(x.typ_) && !hasNil(x.typ_) {
+ check.errorf(&x, InvalidExprSwitch, "cannot switch on %s (%s is not comparable)", &x, x.typ_)
x.mode = invalid
}
} else {
// spec: "A missing switch expression is
// equivalent to the boolean value true."
x.mode = constant_
- x.typ = Typ[Bool]
+ x.typ_ = Typ[Bool]
x.val = constant.MakeBool(true)
// TODO(gri) should have a better position here
pos := s.Rbrace
@@ -786,9 +786,9 @@ func (check *Checker) typeSwitchStmt(inner stmtContext, s *syntax.SwitchStmt, gu
var x operand
check.expr(nil, &x, guard.X)
if x.mode != invalid {
- if isTypeParam(x.typ) {
+ if isTypeParam(x.typ_) {
check.errorf(&x, InvalidTypeSwitch, "cannot use type switch on type parameter value %s", &x)
- } else if IsInterface(x.typ) {
+ } else if IsInterface(x.typ_) {
sx = &x
} else {
check.errorf(&x, InvalidTypeSwitch, "%s is not an interface", &x)
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go
index ac81b838de..49f4dbc249 100644
--- a/src/cmd/compile/internal/types2/typexpr.go
+++ b/src/cmd/compile/internal/types2/typexpr.go
@@ -132,7 +132,7 @@ func (check *Checker) ident(x *operand, e *syntax.Name, wantType bool) {
panic("unreachable")
}
- x.typ = typ
+ x.typ_ = typ
}
// typ type-checks the type expression e and returns its type, or Typ[Invalid].
@@ -250,7 +250,7 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *TypeName) (T Type) {
switch x.mode {
case typexpr:
- return x.typ
+ return x.typ_
case invalid:
// ignore - error reported before
case novalue:
@@ -265,7 +265,7 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *TypeName) (T Type) {
switch x.mode {
case typexpr:
- return x.typ
+ return x.typ_
case invalid:
// ignore - error reported before
case novalue:
@@ -489,7 +489,7 @@ func (check *Checker) arrayLength(e syntax.Expr) int64 {
return -1
}
- if isUntyped(x.typ) || isInteger(x.typ) {
+ if isUntyped(x.typ_) || isInteger(x.typ_) {
if val := constant.ToInt(x.val); val.Kind() == constant.Int {
if representableConst(val, check, Typ[Int], nil) {
if n, ok := constant.Int64Val(val); ok && n >= 0 {
@@ -500,7 +500,7 @@ func (check *Checker) arrayLength(e syntax.Expr) int64 {
}
var msg string
- if isInteger(x.typ) {
+ if isInteger(x.typ_) {
msg = "invalid array length %s"
} else {
msg = "array length %s must be integer"