]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: mechanically rename operand.mode to operand.mode_
authorMark Freeman <mark@golang.org>
Wed, 4 Feb 2026 20:57:34 +0000 (15:57 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 5 Feb 2026 22:00:57 +0000 (14:00 -0800)
Change-Id: I7a978b4a448a25c596c8af346e2ebc11f0ed67e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/742080
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
30 files changed:
src/cmd/compile/internal/types2/api_predicates.go
src/cmd/compile/internal/types2/assignments.go
src/cmd/compile/internal/types2/builtins.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/const.go
src/cmd/compile/internal/types2/conversions.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/index.go
src/cmd/compile/internal/types2/infer.go
src/cmd/compile/internal/types2/literals.go
src/cmd/compile/internal/types2/operand.go
src/cmd/compile/internal/types2/range.go
src/cmd/compile/internal/types2/recording.go
src/cmd/compile/internal/types2/stmt.go
src/cmd/compile/internal/types2/typexpr.go
src/go/types/api_predicates.go
src/go/types/assignments.go
src/go/types/builtins.go
src/go/types/call.go
src/go/types/const.go
src/go/types/conversions.go
src/go/types/expr.go
src/go/types/index.go
src/go/types/infer.go
src/go/types/literals.go
src/go/types/operand.go
src/go/types/range.go
src/go/types/recording.go
src/go/types/stmt.go
src/go/types/typexpr.go

index a1be5de5f476204d5992da47cb02372534a00830..f41890d66cc9a1f4ffd0a3c48484ce339b863a21 100644 (file)
@@ -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
 }
 
index 03ad0085ba572d71a6d6c9bed2e24dda659cd8ea..cbe30b0201fe3473df119c02b2786a065fade328 100644 (file)
@@ -21,7 +21,7 @@ import (
 func (check *Checker) assignment(x *operand, T Type, context string) {
        check.singleValue(x)
 
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                return // error reported before
        case nilvalue:
@@ -33,7 +33,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                // we may get here because of other problems (go.dev/issue/39634, crash 12)
                // TODO(gri) do we need a new "generic" error code here?
                check.errorf(x, IncompatibleAssign, "cannot assign %s to %s in %s", x, T, context)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -48,7 +48,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                        if x.isNil() {
                                if T == nil {
                                        check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
-                                       x.mode = invalid
+                                       x.mode_ = invalid
                                        return
                                }
                        } else if T == nil || isNonTypeParamInterface(T) {
@@ -58,7 +58,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                        if T == nil || isNonTypeParamInterface(T) {
                                if T == nil && x.typ_ == Typ[UntypedNil] {
                                        check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
-                                       x.mode = invalid
+                                       x.mode_ = invalid
                                        return
                                }
                                target = Default(x.typ_)
@@ -76,7 +76,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                                code = IncompatibleAssign
                        }
                        check.error(x, code, msg)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
                if val != nil {
@@ -93,7 +93,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
        // A generic (non-instantiated) function value cannot be assigned to a variable.
        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
+               x.mode_ = invalid
                return
        }
 
@@ -111,12 +111,12 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                } else {
                        check.errorf(x, code, "cannot use %s as %s value in %s", x, T, context)
                }
-               x.mode = invalid
+               x.mode_ = invalid
        }
 }
 
 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]
                }
@@ -124,7 +124,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) {
        }
 
        // rhs must be a constant
-       if x.mode != constant_ {
+       if x.mode_ != constant_ {
                check.errorf(x, InvalidConstInit, "%s is not constant", x)
                if lhs.typ == nil {
                        lhs.typ = Typ[Invalid]
@@ -139,7 +139,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) {
        }
 
        check.assignment(x, lhs.typ, "constant declaration")
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
 
@@ -151,11 +151,11 @@ 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]
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -167,7 +167,7 @@ func (check *Checker) initVar(lhs *Var, x *operand, context string) {
                        if typ == Typ[UntypedNil] {
                                check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
                                lhs.typ = Typ[Invalid]
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                        typ = Default(typ)
@@ -216,13 +216,13 @@ 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]
        }
 
        // spec: "Each left-hand side operand must be addressable, a map index
        // expression, or the blank identifier. Operands may be parenthesized."
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                return Typ[Invalid]
        case variable, mapindex:
@@ -231,7 +231,7 @@ func (check *Checker) lhsVar(lhs syntax.Expr) Type {
                if sel, ok := x.expr.(*syntax.SelectorExpr); ok {
                        var op operand
                        check.expr(nil, &op, sel.X)
-                       if op.mode == mapindex {
+                       if op.mode_ == mapindex {
                                check.errorf(&x, UnaddressableFieldAssign, "cannot assign to struct field %s in map", ExprString(x.expr))
                                return Typ[Invalid]
                        }
@@ -250,7 +250,7 @@ func (check *Checker) assignVar(lhs, rhs syntax.Expr, x *operand, context string
        T := check.lhsVar(lhs) // nil if lhs is _
        if !isValid(T) {
                if x != nil {
-                       x.mode = invalid
+                       x.mode_ = invalid
                } else {
                        check.use(rhs)
                }
@@ -441,7 +441,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []syntax.Expr, returnStmt sy
                }
                // Only record comma-ok expression if both initializations succeeded
                // (go.dev/issue/59371).
-               if commaOk && rhs[0].mode != invalid && rhs[1].mode != invalid {
+               if commaOk && rhs[0].mode_ != invalid && rhs[1].mode_ != invalid {
                        check.recordCommaOkTypes(orig_rhs[0], rhs)
                }
                return
@@ -449,7 +449,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []syntax.Expr, returnStmt sy
 
        // In all other cases we have an assignment mismatch.
        // Only report a mismatch error if there are no other errors on the rhs.
-       if rhs[0].mode != invalid {
+       if rhs[0].mode_ != invalid {
                if returnStmt != nil {
                        check.returnError(returnStmt, lhs, rhs)
                } else {
@@ -505,7 +505,7 @@ func (check *Checker) assignVars(lhs, orig_rhs []syntax.Expr) {
                }
                // Only record comma-ok expression if both assignments succeeded
                // (go.dev/issue/59371).
-               if commaOk && rhs[0].mode != invalid && rhs[1].mode != invalid {
+               if commaOk && rhs[0].mode_ != invalid && rhs[1].mode_ != invalid {
                        check.recordCommaOkTypes(orig_rhs[0], rhs)
                }
                return
@@ -513,7 +513,7 @@ func (check *Checker) assignVars(lhs, orig_rhs []syntax.Expr) {
 
        // In all other cases we have an assignment mismatch.
        // Only report a mismatch error if there are no other errors on the rhs.
-       if rhs[0].mode != invalid {
+       if rhs[0].mode_ != invalid {
                check.assignError(orig_rhs, l, r)
        }
        check.useLHS(lhs...)
index b544dd94f0075ad311d6a3477fbf0cb8a3e257bf..6cc0993c50c8bf4b110f66216caae0820b948de1 100644 (file)
@@ -53,7 +53,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                args = check.exprList(argList)
                nargs = len(args)
                for _, a := range args {
-                       if a.mode == invalid {
+                       if a.mode_ == invalid {
                                return
                        }
                }
@@ -140,7 +140,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, sig)
                }
-               x.mode = value
+               x.mode_ = value
                // x.typ is unchanged
 
        case _Cap, _Len:
@@ -151,7 +151,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                switch t := arrayPtrDeref(x.typ_.Underlying()).(type) {
                case *Basic:
                        if isString(t) && id == _Len {
-                               if x.mode == constant_ {
+                               if x.mode_ == constant_ {
                                        mode = constant_
                                        val = constant.MakeInt64(int64(len(constant.StringVal(x.val))))
                                } else {
@@ -222,7 +222,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ_))
                }
 
-               x.mode = mode
+               x.mode_ = mode
                x.typ_ = Typ[Int]
                x.val = val
 
@@ -241,7 +241,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        return
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, x.typ_))
                }
@@ -262,7 +262,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }) {
                        return
                }
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, x.typ_))
                }
@@ -297,7 +297,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        //    both of them to float64 since they must have the
                        //    same type to succeed (this will result in an error
                        //    because shifts of floats are not permitted)
-                       if x.mode == constant_ && y.mode == constant_ {
+                       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]
@@ -312,7 +312,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                                // and check below
                        }
                }
-               if x.mode == invalid || y.mode == invalid {
+               if x.mode_ == invalid || y.mode_ == invalid {
                        return
                }
 
@@ -345,13 +345,13 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }
 
                // if both arguments are constants, the result is a constant
-               if x.mode == constant_ && y.mode == constant_ {
+               if x.mode_ == constant_ && y.mode_ == constant_ {
                        x.val = constant.BinaryOp(constant.ToFloat(x.val), token.ADD, constant.MakeImag(constant.ToFloat(y.val)))
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
 
-               if check.recordTypes() && x.mode != constant_ {
+               if check.recordTypes() && x.mode_ != constant_ {
                        check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ_, x.typ_))
                }
 
@@ -411,7 +411,7 @@ 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_))
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = Typ[Int]
 
        case _Delete:
@@ -438,11 +438,11 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
                *x = *args[1] // key
                check.assignment(x, key, "argument to delete")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, map_, key))
                }
@@ -453,7 +453,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
 
                // convert or check untyped argument
                if isUntyped(x.typ_) {
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                // an untyped constant number can always be considered
                                // as a complex constant
                                if isNumeric(x.typ_) {
@@ -466,7 +466,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                                // result in an error (shift of complex value)
                                check.convertUntyped(x, Typ[Complex128])
                                // x should be invalid now, but be conservative and check
-                               if x.mode == invalid {
+                               if x.mode_ == invalid {
                                        return
                                }
                        }
@@ -499,17 +499,17 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }
 
                // if the argument is a constant, the result is a constant
-               if x.mode == constant_ {
+               if x.mode_ == constant_ {
                        if id == _Real {
                                x.val = constant.Real(x.val)
                        } else {
                                x.val = constant.Imag(x.val)
                        }
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
 
-               if check.recordTypes() && x.mode != constant_ {
+               if check.recordTypes() && x.mode_ != constant_ {
                        check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ_))
                }
 
@@ -568,7 +568,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        check.error(argList[1], SwappedMakeArgs, invalidArg+"length and capacity swapped")
                        // safe to continue
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = T
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, types...))
@@ -585,7 +585,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }
 
                for i, a := range args {
-                       if a.mode == invalid {
+                       if a.mode_ == invalid {
                                return
                        }
 
@@ -597,7 +597,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        // The first argument is already in x and there's nothing left to do.
                        if i > 0 {
                                check.matchTypes(x, a)
-                               if x.mode == invalid {
+                               if x.mode_ == invalid {
                                        return
                                }
 
@@ -606,22 +606,22 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                                        return
                                }
 
-                               if x.mode == constant_ && a.mode == constant_ {
+                               if x.mode_ == constant_ && a.mode_ == constant_ {
                                        if constant.Compare(a.val, op, x.val) {
                                                *x = *a
                                        }
                                } else {
-                                       x.mode = value
+                                       x.mode_ = value
                                }
                        }
                }
 
                // If nargs == 1, make sure x.mode is either a value or a constant.
-               if x.mode != constant_ {
-                       x.mode = value
+               if x.mode_ != constant_ {
+                       x.mode_ = value
                        // A value must not be untyped.
                        check.assignment(x, &emptyInterface, "argument to built-in "+bin.name)
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                return
                        }
                }
@@ -631,7 +631,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        check.updateExprType(a.expr, x.typ_, true)
                }
 
-               if check.recordTypes() && x.mode != constant_ {
+               if check.recordTypes() && x.mode_ != constant_ {
                        types := make([]Type, nargs)
                        for i := range types {
                                types[i] = x.typ_
@@ -645,7 +645,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                arg := argList[0]
                check.exprOrType(x, arg, false)
                check.exclude(x, 1<<novalue|1<<builtin)
-               switch x.mode {
+               switch x.mode_ {
                case invalid:
                        return
                case typexpr:
@@ -656,7 +656,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        if isUntyped(x.typ_) {
                                // check for overflow and untyped nil
                                check.assignment(x, nil, "argument to new")
-                               if x.mode == invalid {
+                               if x.mode_ == invalid {
                                        return
                                }
                                assert(isTyped(x.typ_))
@@ -666,7 +666,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }
 
                T := x.typ_
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewPointer(T)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, T))
@@ -688,11 +688,11 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }
 
                check.assignment(x, &emptyInterface, "argument to panic")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, &emptyInterface))
                }
@@ -705,21 +705,21 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        params = make([]Type, nargs)
                        for i, a := range args {
                                check.assignment(a, nil, "argument to built-in "+predeclaredFuncs[id].name)
-                               if a.mode == invalid {
+                               if a.mode_ == invalid {
                                        return
                                }
                                params[i] = a.typ_
                        }
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, params...))
                }
 
        case _Recover:
                // recover() interface{}
-               x.mode = value
+               x.mode_ = value
                x.typ_ = &emptyInterface
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_))
@@ -730,7 +730,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                check.verifyVersionf(call.Fun, go1_17, "unsafe.Add")
 
                check.assignment(x, Typ[UnsafePointer], "argument to unsafe.Add")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
@@ -739,7 +739,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = Typ[UnsafePointer]
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, x.typ_, y.typ_))
@@ -748,17 +748,17 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
        case _Alignof:
                // unsafe.Alignof(x T) uintptr
                check.assignment(x, nil, "argument to unsafe.Alignof")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
                if check.hasVarSize(x.typ_) {
-                       x.mode = value
+                       x.mode_ = value
                        if check.recordTypes() {
                                check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ_))
                        }
                } else {
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.val = constant.MakeInt64(check.conf.alignof(x.typ_))
                        // result is constant - no need to record signature
                }
@@ -776,7 +776,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                }
 
                check.expr(nil, x, selx.X)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
@@ -806,7 +806,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                // record the selector expression (was bug - go.dev/issue/47895)
                {
                        mode := value
-                       if x.mode == variable || indirect {
+                       if x.mode_ == variable || indirect {
                                mode = variable
                        }
                        check.record(&operand{mode, selx, obj.Type(), nil, 0})
@@ -817,7 +817,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                // simpler and also permits (or at least doesn't prevent) a compiler from re-
                // arranging struct fields if it wanted to.
                if check.hasVarSize(base) {
-                       x.mode = value
+                       x.mode_ = value
                        if check.recordTypes() {
                                check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], obj.Type()))
                        }
@@ -827,7 +827,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                                check.errorf(x, TypeTooLarge, "%s is too large", x)
                                return
                        }
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.val = constant.MakeInt64(offs)
                        // result is constant - no need to record signature
                }
@@ -836,12 +836,12 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
        case _Sizeof:
                // unsafe.Sizeof(x T) uintptr
                check.assignment(x, nil, "argument to unsafe.Sizeof")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
                if check.hasVarSize(x.typ_) {
-                       x.mode = value
+                       x.mode_ = value
                        if check.recordTypes() {
                                check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ_))
                        }
@@ -851,7 +851,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                                check.errorf(x, TypeTooLarge, "%s is too large", x)
                                return
                        }
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.val = constant.MakeInt64(size)
                        // result is constant - no need to record signature
                }
@@ -873,7 +873,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewSlice(ptr.base)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, ptr, y.typ_))
@@ -890,7 +890,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewPointer(slice.elem)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, slice))
@@ -901,7 +901,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                check.verifyVersionf(call.Fun, go1_20, "unsafe.String")
 
                check.assignment(x, NewPointer(universeByte), "argument to unsafe.String")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
@@ -910,7 +910,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = Typ[String]
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, NewPointer(universeByte), y.typ_))
@@ -921,11 +921,11 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                check.verifyVersionf(call.Fun, go1_20, "unsafe.StringData")
 
                check.assignment(x, Typ[String], "argument to unsafe.StringData")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewPointer(universeByte)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, Typ[String]))
@@ -935,7 +935,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                // 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
                }
@@ -957,7 +957,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                // (no argument evaluated yet)
                if nargs == 0 {
                        check.dump("%v: trace() without arguments", atPos(call))
-                       x.mode = novalue
+                       x.mode_ = novalue
                        break
                }
                var t operand
@@ -967,7 +967,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                        check.dump("%v: %s", atPos(x1), x1)
                        x1 = &t // use incoming x only for first argument
                }
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
                // trace is only available in test mode - no need to record signature
@@ -976,7 +976,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) (
                panic("unreachable")
        }
 
-       assert(x.mode != invalid)
+       assert(x.mode_ != invalid)
        return true
 }
 
index f1727d8de1d97dfecacb73ba07e60d6434d04294..8671b13649dc9f4f144269d4c023a463ce525a1b 100644 (file)
@@ -49,7 +49,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
                xlist = syntax.UnpackListExpr(inst.Index)
                targs = check.typeList(xlist)
                if targs == nil {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return nil
                }
                assert(len(targs) == len(xlist))
@@ -63,7 +63,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
        if got > want {
                // Providing too many type arguments is always an error.
                check.errorf(xlist[got-1], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
-               x.mode = invalid
+               x.mode_ = invalid
                return nil
        }
 
@@ -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
                }
 
@@ -113,7 +113,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
                        if !err.empty() {
                                err.report()
                        }
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return nil
                }
                got = len(targs)
@@ -124,7 +124,7 @@ func (check *Checker) funcInst(T *target, pos syntax.Pos, x *operand, inst *synt
        sig = check.instantiateSignature(x.Pos(), x.expr, sig, targs, xlist)
 
        x.typ_ = sig
-       x.mode = value
+       x.mode_ = value
        return nil
 }
 
@@ -175,7 +175,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
                        // Delay function instantiation to argument checking,
                        // where we combine type and value arguments for type
                        // inference.
-                       assert(x.mode == value)
+                       assert(x.mode_ == value)
                        inst = iexpr
                }
                x.expr = iexpr
@@ -185,7 +185,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
        }
        // x.typ may be generic
 
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                check.use(call.ArgList...)
                x.expr = call
@@ -194,11 +194,11 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
        case typexpr:
                // conversion
                check.nonGeneric(nil, x)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return conversion
                }
                T := x.typ_
-               x.mode = invalid
+               x.mode_ = invalid
                // We cannot convert a value to an incomplete type; make sure it's complete.
                if !check.isComplete(T) {
                        x.expr = call
@@ -209,7 +209,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
                        check.errorf(call, WrongArgCount, "missing argument in conversion to %s", T)
                case 1:
                        check.expr(nil, x, call.ArgList[0])
-                       if x.mode != invalid {
+                       if x.mode_ != invalid {
                                if t, _ := T.Underlying().(*Interface); t != nil && !isTypeParam(T) {
                                        if !t.IsMethodSet() {
                                                check.errorf(call, MisplacedConstraintIface, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T)
@@ -233,11 +233,11 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
                // no need to check for non-genericity here
                id := x.id
                if !check.builtin(x, call, id) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                }
                x.expr = call
                // a non-constant result implies a function call
-               if x.mode != invalid && x.mode != constant_ {
+               if x.mode_ != invalid && x.mode_ != constant_ {
                        check.hasCallOrRecv = true
                }
                return predeclaredFuncs[id].kind
@@ -245,7 +245,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
 
        // ordinary function/method call
        // signature may be generic
-       cgocall := x.mode == cgofunc
+       cgocall := x.mode_ == cgofunc
 
        // 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.
@@ -257,7 +257,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
        })
        if err != nil {
                check.errorf(x, InvalidCall, invalidOp+"cannot call %s: %s", x, err.format(check))
-               x.mode = invalid
+               x.mode_ = invalid
                x.expr = call
                return statement
        }
@@ -274,7 +274,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
                targs = check.typeList(xlist)
                if targs == nil {
                        check.use(call.ArgList...)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        x.expr = call
                        return statement
                }
@@ -285,7 +285,7 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
                if got > want {
                        check.errorf(xlist[want], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
                        check.use(call.ArgList...)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        x.expr = call
                        return statement
                }
@@ -317,23 +317,23 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
        // determine result
        switch sig.results.Len() {
        case 0:
-               x.mode = novalue
+               x.mode_ = novalue
        case 1:
                if cgocall {
-                       x.mode = commaerr
+                       x.mode_ = commaerr
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
                typ := sig.results.vars[0].typ // unpack tuple
                // We cannot return a value of an incomplete type; make sure it's complete.
                if !check.isComplete(typ) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        x.expr = call
                        return statement
                }
                x.typ_ = typ
        default:
-               x.mode = value
+               x.mode_ = value
                x.typ_ = sig.results
        }
        x.expr = call
@@ -341,8 +341,8 @@ func (check *Checker) callExpr(x *operand, call *syntax.CallExpr) exprKind {
 
        // 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_) {
-               x.mode = invalid
+       if x.mode_ == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ_) {
+               x.mode_ = invalid
        }
 
        return statement
@@ -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).
@@ -755,27 +755,27 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                        switch exp := exp.(type) {
                        case *Const:
                                assert(exp.Val() != nil)
-                               x.mode = constant_
+                               x.mode_ = constant_
                                x.typ_ = exp.typ
                                x.val = exp.val
                        case *TypeName:
-                               x.mode = typexpr
+                               x.mode_ = typexpr
                                x.typ_ = exp.typ
                        case *Var:
-                               x.mode = variable
+                               x.mode_ = variable
                                x.typ_ = exp.typ
                                if pkg.cgo && strings.HasPrefix(exp.name, "_Cvar_") {
                                        x.typ_ = x.typ_.(*Pointer).base
                                }
                        case *Func:
-                               x.mode = funcMode
+                               x.mode_ = funcMode
                                x.typ_ = exp.typ
                                if pkg.cgo && strings.HasPrefix(exp.name, "_Cmacro_") {
-                                       x.mode = value
+                                       x.mode_ = value
                                        x.typ_ = x.typ_.(*Signature).results.vars[0].typ
                                }
                        case *Builtin:
-                               x.mode = builtin
+                               x.mode_ = builtin
                                x.typ_ = exp.typ
                                x.id = exp.id
                        default:
@@ -788,7 +788,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
        }
 
        check.exprOrType(x, e.X, false)
-       switch x.mode {
+       switch x.mode_ {
        case builtin:
                check.errorf(e.Pos(), UncalledBuiltin, "invalid use of %s in selector expression", x)
                goto Error
@@ -822,7 +822,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                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()) {
@@ -836,7 +836,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                }
 
                if indirect {
-                       if x.mode == typexpr {
+                       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)
                        } else {
                                check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ_)
@@ -848,7 +848,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                if isInterfacePtr(x.typ_) {
                        why = check.interfacePtrError(x.typ_)
                } else {
-                       alt, _, _ := lookupFieldOrMethod(x.typ_, x.mode == variable, check.pkg, sel, true)
+                       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)
@@ -858,17 +858,17 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
 
        switch obj := obj.(type) {
        case *Var:
-               if x.mode == typexpr {
+               if x.mode_ == typexpr {
                        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)
-               if x.mode == variable || indirect {
-                       x.mode = variable
+               if x.mode_ == variable || indirect {
+                       x.mode_ = variable
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
                x.typ_ = obj.typ
 
@@ -876,7 +876,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                check.objDecl(obj) // ensure fully set-up signature
                check.addDeclDep(obj)
 
-               if x.mode == typexpr {
+               if x.mode_ == typexpr {
                        // method expression
                        check.recordSelection(e, MethodExpr, x.typ_, obj, index, indirect)
 
@@ -907,7 +907,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                                }
                        }
                        params = append([]*Var{NewParam(sig.recv.pos, sig.recv.pkg, name, x.typ_)}, params...)
-                       x.mode = value
+                       x.mode_ = value
                        x.typ_ = &Signature{
                                tparams:  sig.tparams,
                                params:   NewTuple(params...),
@@ -921,7 +921,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
                        // addressability, should we report the type &(x.typ) instead?
                        check.recordSelection(e, MethodVal, x.typ_, obj, index, indirect)
 
-                       x.mode = value
+                       x.mode_ = value
 
                        // remove receiver
                        sig := *obj.typ.(*Signature)
@@ -938,7 +938,7 @@ func (check *Checker) selector(x *operand, e *syntax.SelectorExpr, wantType bool
        return
 
 Error:
-       x.mode = invalid
+       x.mode_ = invalid
        x.typ_ = Typ[Invalid]
        x.expr = e
 }
@@ -967,7 +967,7 @@ func (check *Checker) useN(args []syntax.Expr, lhs bool) bool {
 
 func (check *Checker) use1(e syntax.Expr, lhs bool) bool {
        var x operand
-       x.mode = value // anything but invalid
+       x.mode_ = value // anything but invalid
        switch n := syntax.Unparen(e).(type) {
        case nil:
                // nothing to do
@@ -1001,5 +1001,5 @@ func (check *Checker) use1(e syntax.Expr, lhs bool) bool {
        default:
                check.rawExpr(nil, &x, e, nil, true)
        }
-       return x.mode != invalid
+       return x.mode_ != invalid
 }
index 05190a6bc7ce5c1ef82958df2238687702c6ead1..d5e4f8429bc47a27a2f144ab0d785e20b64cf262 100644 (file)
@@ -18,7 +18,7 @@ import (
 // For untyped constants, it checks that the value doesn't become
 // arbitrarily large.
 func (check *Checker) overflow(x *operand, opPos syntax.Pos) {
-       assert(x.mode == constant_)
+       assert(x.mode_ == constant_)
 
        if x.val.Kind() == constant.Unknown {
                // TODO(gri) We should report exactly what went wrong. At the
@@ -238,7 +238,7 @@ func (check *Checker) representable(x *operand, typ *Basic) {
        v, code := check.representation(x, typ)
        if code != 0 {
                check.invalidConversion(code, x, typ)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
        assert(v != nil)
@@ -250,7 +250,7 @@ func (check *Checker) representable(x *operand, typ *Basic) {
 //
 // If no such representation is possible, it returns a non-zero error code.
 func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, Code) {
-       assert(x.mode == constant_)
+       assert(x.mode_ == constant_)
        v := x.val
        if !representableConst(x.val, check, typ, &v) {
                if isNumeric(x.typ_) && isNumeric(typ) {
@@ -292,7 +292,7 @@ func (check *Checker) convertUntyped(x *operand, target Type) {
                        t = safeUnderlying(target)
                }
                check.invalidConversion(code, x, t)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
        if val != nil {
index cbc4fe964bbe3a77074534c7d1364d99c3dbfef0..3544dfc07b58ef09430525faa14ff725c5be9272 100644 (file)
@@ -15,7 +15,7 @@ import (
 // conversion type-checks the conversion T(x).
 // The result is in x.
 func (check *Checker) conversion(x *operand, T Type) {
-       constArg := x.mode == constant_
+       constArg := x.mode_ == constant_
 
        constConvertibleTo := func(T Type, val *constant.Value) bool {
                switch t, _ := T.Underlying().(*Basic); {
@@ -47,7 +47,7 @@ func (check *Checker) conversion(x *operand, T Type) {
                // (go.dev/issue/63563)
                if !ok && isInteger(x.typ_) && isInteger(T) {
                        check.errorf(x, InvalidConversion, "constant %s overflows %s", x.val, T)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        case constArg && isTypeParam(T):
@@ -76,11 +76,11 @@ func (check *Checker) conversion(x *operand, T Type) {
                        }
                        return true
                })
-               x.mode = value // type parameters are not constants
+               x.mode_ = value // type parameters are not constants
        case x.convertibleTo(check, T, &cause):
                // non-constant conversion
                ok = true
-               x.mode = value
+               x.mode_ = value
        }
 
        if !ok {
@@ -89,7 +89,7 @@ func (check *Checker) conversion(x *operand, T Type) {
                } else {
                        check.errorf(x, InvalidConversion, "cannot convert %s to type %s", x, T)
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -110,7 +110,7 @@ func (check *Checker) conversion(x *operand, T Type) {
                        // 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) {
+               } else if x.mode_ == constant_ && isInteger(x.typ_) && allString(T) {
                        final = x.typ_
                }
                check.updateExprType(x.expr, final, true)
index 49b24b48df2a09f25c052bfef94eda79fc3101da..dad04dbb0bc71d8e46017dcc8bf246778c44962b 100644 (file)
@@ -129,7 +129,7 @@ var op2str2 = [...]string{
 
 func (check *Checker) unary(x *operand, e *syntax.Operation) {
        check.expr(nil, x, e.X)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
 
@@ -138,31 +138,31 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
        case syntax.And:
                // spec: "As an exception to the addressability
                // requirement x may also be a composite literal."
-               if _, ok := syntax.Unparen(e.X).(*syntax.CompositeLit); !ok && x.mode != variable {
+               if _, ok := syntax.Unparen(e.X).(*syntax.CompositeLit); !ok && x.mode_ != variable {
                        check.errorf(x, UnaddressableOperand, invalidOp+"cannot take address of %s", x)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
-               x.mode = value
+               x.mode_ = value
                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.mode_ = commaok
                        x.typ_ = elem
                        check.hasCallOrRecv = true
                        return
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
 
        case syntax.Tilde:
                // Provide a better error position and message than what check.op below would do.
                if !allInteger(x.typ_) {
                        check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint")
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
                check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint (use ^ for bitwise complement)")
@@ -170,11 +170,11 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
        }
 
        if !check.op(unaryOpPredicates, x, op) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                if x.val.Kind() == constant.Unknown {
                        // nothing to do (and don't cause an error below in the overflow check)
                        return
@@ -189,7 +189,7 @@ func (check *Checker) unary(x *operand, e *syntax.Operation) {
                return
        }
 
-       x.mode = value
+       x.mode_ = value
        // x.typ remains unchanged
 }
 
@@ -387,7 +387,7 @@ func (check *Checker) updateExprType(x syntax.Expr, typ Type, final bool) {
                // If x is a constant, it must be representable as a value of typ.
                c := operand{old.mode, x, old.typ, old.val, 0}
                check.convertUntyped(&c, typ)
-               if c.mode == invalid {
+               if c.mode_ == invalid {
                        return
                }
        }
@@ -411,7 +411,7 @@ 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) {
+       if x.mode_ == invalid || isTyped(x.typ_) || !isValid(target) {
                return x.typ_, nil, 0
        }
        // x is untyped
@@ -434,7 +434,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
 
        switch u := target.Underlying().(type) {
        case *Basic:
-               if x.mode == constant_ {
+               if x.mode_ == constant_ {
                        v, code := check.representation(x, u)
                        if code != 0 {
                                return nil, nil, code
@@ -494,7 +494,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
 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_) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -569,12 +569,12 @@ func (check *Checker) comparison(x, y *operand, op syntax.Operator, switchCase b
        }
 
        // comparison is ok
-       if x.mode == constant_ && y.mode == constant_ {
+       if x.mode_ == constant_ && y.mode_ == constant_ {
                x.val = constant.MakeBool(constant.Compare(x.val, op2tok[op], y.val))
                // The operands are never materialized; no need to update
                // their types.
        } else {
-               x.mode = value
+               x.mode_ = value
                // The operands have now their final types, which at run-
                // time will be materialized. Update the expression trees.
                // If the current types are untyped, the materialized type
@@ -611,7 +611,7 @@ Error:
        } else {
                check.errorf(errOp, code, invalidOp+"%s %s %s (%s)", x.expr, op, y.expr, cause)
        }
-       x.mode = invalid
+       x.mode_ = invalid
 }
 
 // incomparableCause returns a more specific cause why typ is not comparable.
@@ -630,7 +630,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
        // TODO(gri) This function seems overly complex. Revisit.
 
        var xval constant.Value
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                xval = constant.ToInt(x.val)
        }
 
@@ -640,7 +640,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
        } else {
                // shift has no chance
                check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -650,12 +650,12 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
        // Check that constants are representable by uint, but do not convert them
        // (see also go.dev/issue/47243).
        var yval constant.Value
-       if y.mode == constant_ {
+       if y.mode_ == constant_ {
                // Provide a good error message for negative shift counts.
                yval = constant.ToInt(y.val) // consider -1, 1.0, but not -1.1
                if yval.Kind() == constant.Int && constant.Sign(yval) < 0 {
                        check.errorf(y, InvalidShiftCount, invalidOp+"negative shift count %s", y)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
 
@@ -663,8 +663,8 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
                        // 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])
-                       if y.mode == invalid {
-                               x.mode = invalid
+                       if y.mode_ == invalid {
+                               x.mode_ = invalid
                                return
                        }
                }
@@ -673,26 +673,26 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
                switch {
                case allInteger(y.typ_):
                        if !allUnsigned(y.typ_) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) {
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                case isUntyped(y.typ_):
                        // This is incorrect, but preserves pre-existing behavior.
                        // See also go.dev/issue/47410.
                        check.convertUntyped(y, Typ[Uint])
-                       if y.mode == invalid {
-                               x.mode = invalid
+                       if y.mode_ == invalid {
+                               x.mode_ = invalid
                                return
                        }
                default:
                        check.errorf(y, InvalidShiftCount, invalidOp+"shift count %s must be integer", y)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        }
 
-       if x.mode == constant_ {
-               if y.mode == constant_ {
+       if x.mode_ == constant_ {
+               if y.mode_ == constant_ {
                        // if either x or y has an unknown value, the result is unknown
                        if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown {
                                x.val = constant.MakeUnknown()
@@ -707,7 +707,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
                        s, ok := constant.Uint64Val(yval)
                        if !ok || s > shiftBound {
                                check.errorf(y, InvalidShiftCount, invalidOp+"invalid shift count %s", y)
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                        // The lhs is representable as an integer but may not be an integer
@@ -750,7 +750,7 @@ func (check *Checker) shift(x, y *operand, e syntax.Expr, op syntax.Operator) {
                                check.untyped[x.expr] = info
                        }
                        // keep x's type
-                       x.mode = value
+                       x.mode_ = value
                        return
                }
        }
@@ -758,11 +758,11 @@ 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_) {
                check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
-       x.mode = value
+       x.mode_ = value
 }
 
 var binaryOpPredicates opPredicates
@@ -794,11 +794,11 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
        check.expr(nil, x, lhs)
        check.expr(nil, &y, rhs)
 
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
-       if y.mode == invalid {
-               x.mode = invalid
+       if y.mode_ == invalid {
+               x.mode_ = invalid
                x.expr = y.expr
                return
        }
@@ -809,7 +809,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
        }
 
        check.matchTypes(x, &y)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
 
@@ -828,36 +828,36 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
                                check.errorf(x, MismatchedTypes, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ_, y.typ_)
                        }
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
        if !check.op(binaryOpPredicates, x, op) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
        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
+                       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 {
                                check.error(&y, DivByZero, invalidOp+"division by zero")
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                }
        }
 
-       if x.mode == constant_ && y.mode == constant_ {
+       if x.mode_ == constant_ && y.mode_ == constant_ {
                // if either x or y has an unknown value, the result is unknown
                if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown {
                        x.val = constant.MakeUnknown()
@@ -875,7 +875,7 @@ func (check *Checker) binary(x *operand, e syntax.Expr, lhs, rhs syntax.Expr, op
                return
        }
 
-       x.mode = value
+       x.mode_ = value
        // x.typ is unchanged
 }
 
@@ -932,12 +932,12 @@ func (check *Checker) matchTypes(x, y *operand) {
 
        if mayConvert(x, y) {
                check.convertUntyped(x, y.typ_)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
                check.convertUntyped(y, x.typ_)
-               if y.mode == invalid {
-                       x.mode = invalid
+               if y.mode_ == invalid {
+                       x.mode_ = invalid
                        return
                }
        }
@@ -1003,7 +1003,7 @@ func (check *Checker) rawExpr(T *target, x *operand, e syntax.Expr, hint Type, a
 // from a non-nil target T, nonGeneric reports an error and invalidates x.mode and x.typ.
 // Otherwise it leaves x alone.
 func (check *Checker) nonGeneric(T *target, x *operand) {
-       if x.mode == invalid || x.mode == novalue {
+       if x.mode_ == invalid || x.mode_ == novalue {
                return
        }
        var what string
@@ -1023,7 +1023,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.mode_ = invalid
                x.typ_ = Typ[Invalid]
        }
 }
@@ -1034,7 +1034,7 @@ func (check *Checker) nonGeneric(T *target, x *operand) {
 func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Type) exprKind {
        // make sure x has a valid state in case of bailout
        // (was go.dev/issue/5770)
-       x.mode = invalid
+       x.mode_ = invalid
        x.typ_ = Typ[Invalid]
 
        switch e := e.(type) {
@@ -1057,19 +1057,19 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
                        goto Error // error reported during parsing
                }
                check.basicLit(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *syntax.FuncLit:
                check.funcLit(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *syntax.CompositeLit:
                check.compositeLit(x, e, hint)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
@@ -1089,19 +1089,19 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
                        }
                        check.funcInst(T, e.Pos(), x, e, true)
                }
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *syntax.SliceExpr:
                check.sliceExpr(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *syntax.AssertExpr:
                check.expr(nil, x, e.X)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
                // x.(type) expressions are encoded via TypeSwitchGuards
@@ -1126,7 +1126,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
                        goto Error
                }
                check.typeAssertion(e, x, T, false)
-               x.mode = commaok
+               x.mode_ = commaok
                x.typ_ = T
 
        case *syntax.TypeSwitchGuard:
@@ -1169,7 +1169,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
                        if e.Op == syntax.Mul {
                                // pointer indirection
                                check.exprOrType(x, e.X, false)
-                               switch x.mode {
+                               switch x.mode_ {
                                case invalid:
                                        goto Error
                                case typexpr:
@@ -1196,14 +1196,14 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
                                        if !check.isComplete(base) {
                                                goto Error
                                        }
-                                       x.mode = variable
+                                       x.mode_ = variable
                                        x.typ_ = base
                                }
                                break
                        }
 
                        check.unary(x, e)
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                goto Error
                        }
                        if e.Op == syntax.Recv {
@@ -1215,7 +1215,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
 
                // binary expression
                check.binary(x, e, e.X, e.Y, e.Op)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
@@ -1226,7 +1226,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.mode_ = typexpr
                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
@@ -1243,7 +1243,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty
        return expression
 
 Error:
-       x.mode = invalid
+       x.mode_ = invalid
        x.expr = e
        return statement // avoid follow-up errors
 }
@@ -1333,20 +1333,20 @@ 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
        }
 
        // 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]}
-               if x.mode == commaerr {
+       if allowCommaOk && (x.mode_ == mapindex || x.mode_ == commaok || x.mode_ == commaerr) {
+               x2 := &operand{mode_: value, expr: e, typ_: Typ[UntypedBool]}
+               if x.mode_ == commaerr {
                        x2.typ_ = universeError
                }
                list = append(list, x2)
@@ -1379,10 +1379,10 @@ func (check *Checker) exprOrType(x *operand, e syntax.Expr, allowGeneric bool) {
 // exclude reports an error if x.mode is in modeset and sets x.mode to invalid.
 // The modeset may contain any of 1<<novalue, 1<<builtin, 1<<typexpr.
 func (check *Checker) exclude(x *operand, modeset uint) {
-       if modeset&(1<<x.mode) != 0 {
+       if modeset&(1<<x.mode_) != 0 {
                var msg string
                var code Code
-               switch x.mode {
+               switch x.mode_ {
                case novalue:
                        if modeset&(1<<typexpr) != 0 {
                                msg = "%s used as value"
@@ -1400,18 +1400,18 @@ func (check *Checker) exclude(x *operand, modeset uint) {
                        panic("unreachable")
                }
                check.errorf(x, code, msg, x)
-               x.mode = invalid
+               x.mode_ = invalid
        }
 }
 
 // singleValue reports an error if x describes a tuple and sets x.mode to invalid.
 func (check *Checker) singleValue(x *operand) {
-       if x.mode == value {
+       if x.mode_ == value {
                // tuple types are never named - no need for underlying type below
                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
+                       x.mode_ = invalid
                }
        }
 }
index 6c659a599d77cee85b14c4c0c454f7a8359e2754..2a98ef881527b18deb48bef47d1f9d0aa4b74fc6 100644 (file)
@@ -19,18 +19,18 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
        check.exprOrType(x, e.X, true)
        // x may be generic
 
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                check.use(e.Index)
                return false
 
        case typexpr:
                // type instantiation
-               x.mode = invalid
+               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.mode = typexpr
+                       x.mode_ = typexpr
                }
                return false
 
@@ -43,13 +43,13 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
 
        // x should not be generic at this point, but be safe and check
        check.nonGeneric(nil, x)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return false
        }
 
        // We cannot index on an incomplete type; make sure it's complete.
        if !check.isComplete(x.typ_) {
-               x.mode = invalid
+               x.mode_ = invalid
                return false
        }
        switch typ := x.typ_.Underlying().(type) {
@@ -57,14 +57,14 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
                // Additionally, if x.typ is a pointer to an array type, indexing implicitly dereferences the value, meaning
                // its base type must also be complete.
                if !check.isComplete(typ.base) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return false
                }
        case *Map:
                // Lastly, if x.typ is a map type, indexing must produce a value of a complete type, meaning
                // its element type must also be complete.
                if !check.isComplete(typ.elem) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return false
                }
        }
@@ -76,21 +76,21 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
        case *Basic:
                if isString(typ) {
                        valid = true
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                length = int64(len(constant.StringVal(x.val)))
                        }
                        // an indexed string always yields a byte value
                        // (not a constant) even if the string and the
                        // index are constant
-                       x.mode = value
+                       x.mode_ = value
                        x.typ_ = universeByte // use 'byte' name
                }
 
        case *Array:
                valid = true
                length = typ.len
-               if x.mode != variable {
-                       x.mode = value
+               if x.mode_ != variable {
+                       x.mode_ = value
                }
                x.typ_ = typ.elem
 
@@ -98,26 +98,26 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
                if typ, _ := typ.base.Underlying().(*Array); typ != nil {
                        valid = true
                        length = typ.len
-                       x.mode = variable
+                       x.mode_ = variable
                        x.typ_ = typ.elem
                }
 
        case *Slice:
                valid = true
-               x.mode = variable
+               x.mode_ = variable
                x.typ_ = typ.elem
 
        case *Map:
                index := check.singleIndex(e)
                if index == nil {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return false
                }
                var key operand
                check.expr(nil, &key, index)
                check.assignment(&key, typ.key, "map index")
                // ok to continue even if indexing failed - map element type is known
-               x.mode = mapindex
+               x.mode_ = mapindex
                x.typ_ = typ.elem
                x.expr = e
                return false
@@ -142,7 +142,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
                        case *Array:
                                l = t.len
                                e = t.elem
-                               if x.mode != variable {
+                               if x.mode_ != variable {
                                        mode = value
                                }
                        case *Pointer:
@@ -184,14 +184,14 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
                        if key != nil {
                                index := check.singleIndex(e)
                                if index == nil {
-                                       x.mode = invalid
+                                       x.mode_ = invalid
                                        return false
                                }
                                var k operand
                                check.expr(nil, &k, index)
                                check.assignment(&k, key, "map index")
                                // ok to continue even if indexing failed - map element type is known
-                               x.mode = mapindex
+                               x.mode_ = mapindex
                                x.typ_ = elem
                                x.expr = e
                                return false
@@ -199,7 +199,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
 
                        // no maps
                        valid = true
-                       x.mode = mode
+                       x.mode_ = mode
                        x.typ_ = elem
                }
        }
@@ -207,13 +207,13 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
        if !valid {
                check.errorf(e.Pos(), NonSliceableOperand, "cannot index %s", x)
                check.use(e.Index)
-               x.mode = invalid
+               x.mode_ = invalid
                return false
        }
 
        index := check.singleIndex(e)
        if index == nil {
-               x.mode = invalid
+               x.mode_ = invalid
                return false
        }
 
@@ -230,7 +230,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo
 
 func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
        check.expr(nil, x, e.X)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                check.use(e.Index[:]...)
                return
        }
@@ -277,7 +277,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
        // 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) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -286,7 +286,7 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
        switch u := cu.(type) {
        case nil:
                // error reported above
-               x.mode = invalid
+               x.mode_ = invalid
                return
 
        case *Basic:
@@ -297,11 +297,11 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
                                        at = e // e.Index[2] should be present but be careful
                                }
                                check.error(at, InvalidSliceExpr, invalidOp+"3-index slice of string")
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                        valid = true
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                length = int64(len(constant.StringVal(x.val)))
                        }
                        // spec: "For untyped string operands the result
@@ -314,9 +314,9 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
        case *Array:
                valid = true
                length = u.len
-               if x.mode != variable {
+               if x.mode_ != variable {
                        check.errorf(x, NonSliceableOperand, "cannot slice unaddressable value %s", x)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
                x.typ_ = &Slice{elem: u.elem}
@@ -335,16 +335,16 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
 
        if !valid {
                check.errorf(x, NonSliceableOperand, "cannot slice %s", x)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
-       x.mode = value
+       x.mode_ = value
 
        // spec: "Only the first index may be omitted; it defaults to 0."
        if e.Full && (e.Index[1] == nil || e.Index[2] == nil) {
                check.error(e, InvalidSyntaxTree, "2nd and 3rd index required in 3-index slice")
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -427,7 +427,7 @@ func (check *Checker) index(index syntax.Expr, max int64) (typ Type, val int64)
                return
        }
 
-       if x.mode != constant_ {
+       if x.mode_ != constant_ {
                return x.typ_, -1
        }
 
@@ -451,13 +451,13 @@ func (check *Checker) index(index syntax.Expr, max int64) (typ Type, val int64)
 // If the operand is not valid, an error is reported (using what as context)
 // and the result is false.
 func (check *Checker) isValidIndex(x *operand, code Code, what string, allowNegative bool) bool {
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return false
        }
 
        // spec: "a constant index that is untyped is given type int"
        check.convertUntyped(x, Typ[Int])
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return false
        }
 
@@ -467,7 +467,7 @@ func (check *Checker) isValidIndex(x *operand, code Code, what string, allowNega
                return false
        }
 
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                // spec: "a constant index must be non-negative ..."
                if !allowNegative && constant.Sign(x.val) < 0 {
                        check.errorf(x, code, invalidArg+"%s %s must not be negative", what, x)
index 5ba3583916368d34da6737fb2f923634e5dc2a6e..7a0acd2e31419c39b40cc8f97bfbbddf0b2319a2 100644 (file)
@@ -62,7 +62,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
        // If we have invalid (ordinary) arguments, an error was reported before.
        // Avoid additional inference errors and exit early (go.dev/issue/60434).
        for _, arg := range args {
-               if arg.mode == invalid {
+               if arg.mode_ == invalid {
                        return nil
                }
        }
@@ -162,7 +162,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type,
        }
 
        for i, arg := range args {
-               if arg.mode == invalid {
+               if arg.mode_ == invalid {
                        // An error was reported earlier. Ignore this arg
                        // and continue, we may still be able to infer all
                        // targs resulting in fewer follow-on errors.
index 893f37caa50bf324e50a8765a81147ffa870ef15..8da6345bc12b06dc3d9d301a1f1278891c9a25d3 100644 (file)
@@ -57,18 +57,18 @@ func (check *Checker) basicLit(x *operand, e *syntax.BasicLit) {
                const limit = 10000
                if len(e.Value) > limit {
                        check.errorf(e, InvalidConstVal, "excessively long constant: %s... (%d chars)", e.Value[:10], len(e.Value))
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        }
        x.setConst(e.Kind, e.Value)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                // The parser already establishes syntactic correctness.
                // If we reach here it's because of number under-/overflow.
                // TODO(gri) setConst (and in turn the go/constant package)
                // should return an error describing the issue.
                check.errorf(e, InvalidConstVal, "malformed constant: %s", e.Value)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
        // Ensure that integer values don't overflow (go.dev/issue/54280).
@@ -96,11 +96,11 @@ func (check *Checker) funcLit(x *operand, e *syntax.FuncLit) {
                                check.funcBody(decl, "<function literal>", sig, e.Body, iota)
                        }).describef(e, "func literal")
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = sig
        } else {
                check.errorf(e, InvalidSyntaxTree, "invalid function literal %v", e)
-               x.mode = invalid
+               x.mode_ = invalid
        }
 }
 
@@ -145,7 +145,7 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
 
        // We cannot create a literal of an incomplete type; make sure it's complete.
        if !check.isComplete(base) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -261,10 +261,10 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
                        }
                        check.exprWithHint(x, kv.Key, utyp.key)
                        check.assignment(x, utyp.key, "map literal")
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                continue
                        }
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                duplicate := false
                                xkey := keyVal(x.val)
                                if keyIsInterface {
@@ -311,12 +311,12 @@ func (check *Checker) compositeLit(x *operand, e *syntax.CompositeLit, hint Type
                                cause = " (no common underlying type)"
                        }
                        check.errorf(e, InvalidLit, "invalid composite literal%s type %s%s", qualifier, typ, cause)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        }
 
-       x.mode = value
+       x.mode_ = value
        x.typ_ = typ
 }
 
index 884b4edb81ce3990d0fa4aaf8ff4adf8f85e4eee..be10c0a609ad59b6f0b67771dc220f8b7278cf2e 100644 (file)
@@ -53,11 +53,11 @@ var operandModeString = [...]string{
 // for built-in functions.
 // The zero value of operand is a ready to use invalid operand.
 type operand struct {
-       mode operandMode
-       expr syntax.Expr
-       typ_ Type
-       val  constant.Value
-       id   builtinId
+       mode_ operandMode
+       expr  syntax.Expr
+       typ_  Type
+       val   constant.Value
+       id    builtinId
 }
 
 // Pos returns the position of the expression corresponding to x.
@@ -109,7 +109,7 @@ func (x *operand) Pos() syntax.Pos {
 func operandString(x *operand, qf Qualifier) string {
        // special-case nil
        if isTypes2 {
-               if x.mode == nilvalue {
+               if x.mode_ == nilvalue {
                        switch x.typ_ {
                        case nil, Typ[Invalid]:
                                return "nil (with invalid type)"
@@ -120,7 +120,7 @@ func operandString(x *operand, qf Qualifier) string {
                        }
                }
        } else { // go/types
-               if x.mode == value && x.typ_ == Typ[UntypedNil] {
+               if x.mode_ == value && x.typ_ == Typ[UntypedNil] {
                        return "nil"
                }
        }
@@ -131,7 +131,7 @@ func operandString(x *operand, qf Qualifier) string {
        if x.expr != nil {
                expr = ExprString(x.expr)
        } else {
-               switch x.mode {
+               switch x.mode_ {
                case builtin:
                        expr = predeclaredFuncs[x.id].name
                case typexpr:
@@ -149,7 +149,7 @@ func operandString(x *operand, qf Qualifier) string {
 
        // <untyped kind>
        hasType := false
-       switch x.mode {
+       switch x.mode_ {
        case invalid, novalue, builtin, typexpr:
                // no type
        default:
@@ -165,10 +165,10 @@ func operandString(x *operand, qf Qualifier) string {
        }
 
        // <mode>
-       buf.WriteString(operandModeString[x.mode])
+       buf.WriteString(operandModeString[x.mode_])
 
        // <val>
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                if s := x.val.String(); s != expr {
                        buf.WriteByte(' ')
                        buf.WriteString(s)
@@ -281,11 +281,11 @@ func (x *operand) setConst(k syntax.LitKind, lit string) {
 
        val := makeFromLiteral(lit, k)
        if val.Kind() == constant.Unknown {
-               x.mode = invalid
+               x.mode_ = invalid
                x.typ_ = Typ[Invalid]
                return
        }
-       x.mode = constant_
+       x.mode_ = constant_
        x.typ_ = Typ[kind]
        x.val = val
 }
@@ -293,9 +293,9 @@ func (x *operand) setConst(k syntax.LitKind, lit string) {
 // isNil reports whether x is the (untyped) nil value.
 func (x *operand) isNil() bool {
        if isTypes2 {
-               return x.mode == nilvalue
+               return x.mode_ == nilvalue
        } else { // go/types
-               return x.mode == value && x.typ_ == Typ[UntypedNil]
+               return x.mode_ == value && x.typ_ == Typ[UntypedNil]
        }
 }
 
@@ -306,7 +306,7 @@ func (x *operand) isNil() bool {
 // if assignableTo is invoked through an exported API call, i.e., when all
 // methods have been type-checked.
 func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Code) {
-       if x.mode == invalid || !isValid(T) {
+       if x.mode_ == invalid || !isValid(T) {
                return true, 0 // avoid spurious errors
        }
 
index 37a701a0fb0e16818e001f017bb3d506d84c4c36..189aca64ce2d994efc9602a54904f138617c19a1 100644 (file)
@@ -34,7 +34,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
        check.hasCallOrRecv = false
        check.expr(nil, &x, rangeVar)
 
-       if isTypes2 && x.mode != invalid && sValue == nil && !check.hasCallOrRecv {
+       if isTypes2 && x.mode_ != invalid && sValue == nil && !check.hasCallOrRecv {
                if t, ok := arrayPtrDeref(x.typ_.Underlying()).(*Array); ok {
                        for {
                                // Put constant info on the thing inside parentheses.
@@ -50,18 +50,18 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
                        // (and thus side-effects will not be computed
                        // by the backend).
                        check.record(&operand{
-                               mode: constant_,
-                               expr: rangeVar,
-                               typ_: Typ[Int],
-                               val:  constant.MakeInt64(t.len),
-                               id:   x.id,
+                               mode_: constant_,
+                               expr:  rangeVar,
+                               typ_:  Typ[Int],
+                               val:   constant.MakeInt64(t.len),
+                               id:    x.id,
                        })
                }
        }
 
        // determine key/value types
        var key, val Type
-       if x.mode != invalid {
+       if x.mode_ != invalid {
                k, v, cause, ok := rangeKeyVal(check, x.typ_, func(v goVersion) bool {
                        return check.allowVersion(v)
                })
@@ -133,7 +133,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *syntax.ForStmt, no
                                check.initVar(obj, &x, "range clause")
                        } else {
                                var y operand
-                               y.mode = value
+                               y.mode_ = value
                                y.expr = lhs // we don't have a better rhs expression to use here
                                y.typ_ = typ
                                check.initVar(obj, &y, "assignment") // error is on variable, use "assignment" not "range clause"
@@ -169,12 +169,12 @@ 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_) {
+                               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.mode_ = value
                                y.expr = lhs // we don't have a better rhs expression to use here
                                y.typ_ = typ
                                check.assignVar(lhs, nil, &y, "assignment") // error is on variable, use "assignment" not "range clause"
index 5a6b295418bf2e44444a4f825f84434aee78cdc8..76e6752e57c23f836eb4e5b381fed718f65086d8 100644 (file)
@@ -17,7 +17,7 @@ func (check *Checker) record(x *operand) {
        // TODO(gri) this code can be simplified
        var typ Type
        var val constant.Value
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                typ = Typ[Invalid]
        case novalue:
@@ -33,9 +33,9 @@ func (check *Checker) record(x *operand) {
        if isUntyped(typ) {
                // delay type and value recording until we know the type
                // or until the end of type checking
-               check.rememberUntyped(x.expr, false, x.mode, typ.(*Basic), val)
+               check.rememberUntyped(x.expr, false, x.mode_, typ.(*Basic), val)
        } else {
-               check.recordTypeAndValue(x.expr, x.mode, typ, val)
+               check.recordTypeAndValue(x.expr, x.mode_, typ, val)
        }
 }
 
@@ -94,7 +94,7 @@ func (check *Checker) recordBuiltinType(f syntax.Expr, sig *Signature) {
 func (check *Checker) recordCommaOkTypes(x syntax.Expr, a []*operand) {
        assert(x != nil)
        assert(len(a) == 2)
-       if a[0].mode == invalid {
+       if a[0].mode_ == invalid {
                return
        }
        t0, t1 := a[0].typ_, a[1].typ_
index 732f8a9b7440a3f4ec881298fb248d8fd5a7d6e4..05941f29c54dfb0ac24ec537c9f9e0541f3a9bbf 100644 (file)
@@ -238,20 +238,20 @@ L:
        for _, e := range values {
                var v operand
                check.expr(nil, &v, e)
-               if x.mode == invalid || v.mode == invalid {
+               if x.mode_ == invalid || v.mode_ == invalid {
                        continue L
                }
                check.convertUntyped(&v, x.typ_)
-               if v.mode == invalid {
+               if v.mode_ == invalid {
                        continue L
                }
                // Order matters: By comparing v against x, error positions are at the case values.
                res := v // keep original v unchanged
                check.comparison(&res, x, syntax.Eql, true)
-               if res.mode == invalid {
+               if res.mode_ == invalid {
                        continue L
                }
-               if v.mode != constant_ {
+               if v.mode_ != constant_ {
                        continue L // we're done
                }
                // look for duplicate values
@@ -444,7 +444,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) {
                kind := check.rawExpr(nil, &x, s.X, nil, false)
                var msg string
                var code Code
-               switch x.mode {
+               switch x.mode_ {
                default:
                        if kind == statement {
                                return
@@ -464,7 +464,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) {
                var ch, val operand
                check.expr(nil, &ch, s.Chan)
                check.expr(nil, &val, s.Value)
-               if ch.mode == invalid || val.mode == invalid {
+               if ch.mode_ == invalid || val.mode_ == invalid {
                        return
                }
                if elem := check.chanElem(s, &ch, false); elem != nil {
@@ -477,7 +477,7 @@ func (check *Checker) stmt(ctxt stmtContext, s syntax.Stmt) {
                        // (no need to call unpackExpr as s.Lhs must be single-valued)
                        var x operand
                        check.expr(nil, &x, s.Lhs)
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                return
                        }
                        if !allNumeric(x.typ_) {
@@ -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,14 +721,14 @@ 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_) {
+               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
+                       x.mode_ = invalid
                }
        } else {
                // spec: "A missing switch expression is
                // equivalent to the boolean value true."
-               x.mode = constant_
+               x.mode_ = constant_
                x.typ_ = Typ[Bool]
                x.val = constant.MakeBool(true)
                // TODO(gri) should have a better position here
@@ -785,7 +785,7 @@ func (check *Checker) typeSwitchStmt(inner stmtContext, s *syntax.SwitchStmt, gu
        {
                var x operand
                check.expr(nil, &x, guard.X)
-               if x.mode != invalid {
+               if x.mode_ != invalid {
                        if isTypeParam(x.typ_) {
                                check.errorf(&x, InvalidTypeSwitch, "cannot use type switch on type parameter value %s", &x)
                        } else if IsInterface(x.typ_) {
index 49f4dbc249143ddaec79e3f8d3a9b67230f1e9ce..a7ea0f611d6a166901314a3ca10e2251e883416b 100644 (file)
@@ -18,7 +18,7 @@ import (
 // If an error occurred, x.mode is set to invalid.
 // If wantType is set, the identifier e is expected to denote a type.
 func (check *Checker) ident(x *operand, e *syntax.Name, wantType bool) {
-       x.mode = invalid
+       x.mode_ = invalid
        x.expr = e
 
        scope, obj := check.lookupScope(e.Value)
@@ -99,10 +99,10 @@ func (check *Checker) ident(x *operand, e *syntax.Name, wantType bool) {
                        x.val = obj.val
                }
                assert(x.val != nil)
-               x.mode = constant_
+               x.mode_ = constant_
 
        case *TypeName:
-               x.mode = typexpr
+               x.mode_ = typexpr
 
        case *Var:
                // It's ok to mark non-local variables, but ignore variables
@@ -115,18 +115,18 @@ func (check *Checker) ident(x *operand, e *syntax.Name, wantType bool) {
                if !isValid(typ) {
                        return
                }
-               x.mode = variable
+               x.mode_ = variable
 
        case *Func:
                check.addDeclDep(obj)
-               x.mode = value
+               x.mode_ = value
 
        case *Builtin:
                x.id = obj.id
-               x.mode = builtin
+               x.mode_ = builtin
 
        case *Nil:
-               x.mode = nilvalue
+               x.mode_ = nilvalue
 
        default:
                panic("unreachable")
@@ -248,7 +248,7 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *TypeName) (T Type) {
                var x operand
                check.ident(&x, e, true)
 
-               switch x.mode {
+               switch x.mode_ {
                case typexpr:
                        return x.typ_
                case invalid:
@@ -263,7 +263,7 @@ func (check *Checker) typInternal(e0 syntax.Expr, def *TypeName) (T Type) {
                var x operand
                check.selector(&x, e, true)
 
-               switch x.mode {
+               switch x.mode_ {
                case typexpr:
                        return x.typ_
                case invalid:
@@ -482,8 +482,8 @@ func (check *Checker) arrayLength(e syntax.Expr) int64 {
 
        var x operand
        check.expr(nil, &x, e)
-       if x.mode != constant_ {
-               if x.mode != invalid {
+       if x.mode_ != constant_ {
+               if x.mode_ != invalid {
                        check.errorf(&x, InvalidArrayLen, "array length %s must be constant", &x)
                }
                return -1
index d2cc382f2f772725a5f59ebef96f7abf29019900..420723d4978a039ceea51f64a897d8fc3add0cfe 100644 (file)
@@ -31,7 +31,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
 }
@@ -42,7 +42,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
 }
 
index 0cacadb759899704c5d06022c5ecd7bee0e1f053..2955ac2b73d68454e9b5803c6eeddef41da33469 100644 (file)
@@ -24,7 +24,7 @@ import (
 func (check *Checker) assignment(x *operand, T Type, context string) {
        check.singleValue(x)
 
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                return // error reported before
        case nilvalue:
@@ -36,7 +36,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                // we may get here because of other problems (go.dev/issue/39634, crash 12)
                // TODO(gri) do we need a new "generic" error code here?
                check.errorf(x, IncompatibleAssign, "cannot assign %s to %s in %s", x, T, context)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -51,7 +51,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                        if x.isNil() {
                                if T == nil {
                                        check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
-                                       x.mode = invalid
+                                       x.mode_ = invalid
                                        return
                                }
                        } else if T == nil || isNonTypeParamInterface(T) {
@@ -61,7 +61,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                        if T == nil || isNonTypeParamInterface(T) {
                                if T == nil && x.typ_ == Typ[UntypedNil] {
                                        check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
-                                       x.mode = invalid
+                                       x.mode_ = invalid
                                        return
                                }
                                target = Default(x.typ_)
@@ -79,7 +79,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                                code = IncompatibleAssign
                        }
                        check.error(x, code, msg)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
                if val != nil {
@@ -96,7 +96,7 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
        // A generic (non-instantiated) function value cannot be assigned to a variable.
        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
+               x.mode_ = invalid
                return
        }
 
@@ -114,12 +114,12 @@ func (check *Checker) assignment(x *operand, T Type, context string) {
                } else {
                        check.errorf(x, code, "cannot use %s as %s value in %s", x, T, context)
                }
-               x.mode = invalid
+               x.mode_ = invalid
        }
 }
 
 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]
                }
@@ -127,7 +127,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) {
        }
 
        // rhs must be a constant
-       if x.mode != constant_ {
+       if x.mode_ != constant_ {
                check.errorf(x, InvalidConstInit, "%s is not constant", x)
                if lhs.typ == nil {
                        lhs.typ = Typ[Invalid]
@@ -142,7 +142,7 @@ func (check *Checker) initConst(lhs *Const, x *operand) {
        }
 
        check.assignment(x, lhs.typ, "constant declaration")
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
 
@@ -154,11 +154,11 @@ 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]
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -170,7 +170,7 @@ func (check *Checker) initVar(lhs *Var, x *operand, context string) {
                        if typ == Typ[UntypedNil] {
                                check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
                                lhs.typ = Typ[Invalid]
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                        typ = Default(typ)
@@ -219,13 +219,13 @@ func (check *Checker) lhsVar(lhs ast.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]
        }
 
        // spec: "Each left-hand side operand must be addressable, a map index
        // expression, or the blank identifier. Operands may be parenthesized."
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                return Typ[Invalid]
        case variable, mapindex:
@@ -234,7 +234,7 @@ func (check *Checker) lhsVar(lhs ast.Expr) Type {
                if sel, ok := x.expr.(*ast.SelectorExpr); ok {
                        var op operand
                        check.expr(nil, &op, sel.X)
-                       if op.mode == mapindex {
+                       if op.mode_ == mapindex {
                                check.errorf(&x, UnaddressableFieldAssign, "cannot assign to struct field %s in map", ExprString(x.expr))
                                return Typ[Invalid]
                        }
@@ -253,7 +253,7 @@ func (check *Checker) assignVar(lhs, rhs ast.Expr, x *operand, context string) {
        T := check.lhsVar(lhs) // nil if lhs is _
        if !isValid(T) {
                if x != nil {
-                       x.mode = invalid
+                       x.mode_ = invalid
                } else {
                        check.use(rhs)
                }
@@ -444,7 +444,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []ast.Expr, returnStmt ast.S
                }
                // Only record comma-ok expression if both initializations succeeded
                // (go.dev/issue/59371).
-               if commaOk && rhs[0].mode != invalid && rhs[1].mode != invalid {
+               if commaOk && rhs[0].mode_ != invalid && rhs[1].mode_ != invalid {
                        check.recordCommaOkTypes(orig_rhs[0], rhs)
                }
                return
@@ -452,7 +452,7 @@ func (check *Checker) initVars(lhs []*Var, orig_rhs []ast.Expr, returnStmt ast.S
 
        // In all other cases we have an assignment mismatch.
        // Only report a mismatch error if there are no other errors on the rhs.
-       if rhs[0].mode != invalid {
+       if rhs[0].mode_ != invalid {
                if returnStmt != nil {
                        check.returnError(returnStmt, lhs, rhs)
                } else {
@@ -508,7 +508,7 @@ func (check *Checker) assignVars(lhs, orig_rhs []ast.Expr) {
                }
                // Only record comma-ok expression if both assignments succeeded
                // (go.dev/issue/59371).
-               if commaOk && rhs[0].mode != invalid && rhs[1].mode != invalid {
+               if commaOk && rhs[0].mode_ != invalid && rhs[1].mode_ != invalid {
                        check.recordCommaOkTypes(orig_rhs[0], rhs)
                }
                return
@@ -516,7 +516,7 @@ func (check *Checker) assignVars(lhs, orig_rhs []ast.Expr) {
 
        // In all other cases we have an assignment mismatch.
        // Only report a mismatch error if there are no other errors on the rhs.
-       if rhs[0].mode != invalid {
+       if rhs[0].mode_ != invalid {
                check.assignError(orig_rhs, l, r)
        }
        check.useLHS(lhs...)
index bb65981b55a80a7744dca5176d3db558ca0bc4a9..1d4f4a7b432a383f2fb7ebb688b1889515a2f96c 100644 (file)
@@ -56,7 +56,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                args = check.exprList(argList)
                nargs = len(args)
                for _, a := range args {
-                       if a.mode == invalid {
+                       if a.mode_ == invalid {
                                return
                        }
                }
@@ -143,7 +143,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, sig)
                }
-               x.mode = value
+               x.mode_ = value
                // x.typ is unchanged
 
        case _Cap, _Len:
@@ -154,7 +154,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                switch t := arrayPtrDeref(x.typ_.Underlying()).(type) {
                case *Basic:
                        if isString(t) && id == _Len {
-                               if x.mode == constant_ {
+                               if x.mode_ == constant_ {
                                        mode = constant_
                                        val = constant.MakeInt64(int64(len(constant.StringVal(x.val))))
                                } else {
@@ -225,7 +225,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ_))
                }
 
-               x.mode = mode
+               x.mode_ = mode
                x.typ_ = Typ[Int]
                x.val = val
 
@@ -244,7 +244,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        return
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, x.typ_))
                }
@@ -265,7 +265,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }) {
                        return
                }
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, x.typ_))
                }
@@ -300,7 +300,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        //    both of them to float64 since they must have the
                        //    same type to succeed (this will result in an error
                        //    because shifts of floats are not permitted)
-                       if x.mode == constant_ && y.mode == constant_ {
+                       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]
@@ -315,7 +315,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                                // and check below
                        }
                }
-               if x.mode == invalid || y.mode == invalid {
+               if x.mode_ == invalid || y.mode_ == invalid {
                        return
                }
 
@@ -348,13 +348,13 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }
 
                // if both arguments are constants, the result is a constant
-               if x.mode == constant_ && y.mode == constant_ {
+               if x.mode_ == constant_ && y.mode_ == constant_ {
                        x.val = constant.BinaryOp(constant.ToFloat(x.val), token.ADD, constant.MakeImag(constant.ToFloat(y.val)))
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
 
-               if check.recordTypes() && x.mode != constant_ {
+               if check.recordTypes() && x.mode_ != constant_ {
                        check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ_, x.typ_))
                }
 
@@ -414,7 +414,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(Typ[Int], x.typ_, y.typ_))
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = Typ[Int]
 
        case _Delete:
@@ -441,11 +441,11 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
                *x = *args[1] // key
                check.assignment(x, key, "argument to delete")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, map_, key))
                }
@@ -456,7 +456,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
 
                // convert or check untyped argument
                if isUntyped(x.typ_) {
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                // an untyped constant number can always be considered
                                // as a complex constant
                                if isNumeric(x.typ_) {
@@ -469,7 +469,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                                // result in an error (shift of complex value)
                                check.convertUntyped(x, Typ[Complex128])
                                // x should be invalid now, but be conservative and check
-                               if x.mode == invalid {
+                               if x.mode_ == invalid {
                                        return
                                }
                        }
@@ -502,17 +502,17 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }
 
                // if the argument is a constant, the result is a constant
-               if x.mode == constant_ {
+               if x.mode_ == constant_ {
                        if id == _Real {
                                x.val = constant.Real(x.val)
                        } else {
                                x.val = constant.Imag(x.val)
                        }
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
 
-               if check.recordTypes() && x.mode != constant_ {
+               if check.recordTypes() && x.mode_ != constant_ {
                        check.recordBuiltinType(call.Fun, makeSig(resTyp, x.typ_))
                }
 
@@ -571,7 +571,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        check.error(argList[1], SwappedMakeArgs, invalidArg+"length and capacity swapped")
                        // safe to continue
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = T
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, types...))
@@ -588,7 +588,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }
 
                for i, a := range args {
-                       if a.mode == invalid {
+                       if a.mode_ == invalid {
                                return
                        }
 
@@ -600,7 +600,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        // The first argument is already in x and there's nothing left to do.
                        if i > 0 {
                                check.matchTypes(x, a)
-                               if x.mode == invalid {
+                               if x.mode_ == invalid {
                                        return
                                }
 
@@ -609,22 +609,22 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                                        return
                                }
 
-                               if x.mode == constant_ && a.mode == constant_ {
+                               if x.mode_ == constant_ && a.mode_ == constant_ {
                                        if constant.Compare(a.val, op, x.val) {
                                                *x = *a
                                        }
                                } else {
-                                       x.mode = value
+                                       x.mode_ = value
                                }
                        }
                }
 
                // If nargs == 1, make sure x.mode is either a value or a constant.
-               if x.mode != constant_ {
-                       x.mode = value
+               if x.mode_ != constant_ {
+                       x.mode_ = value
                        // A value must not be untyped.
                        check.assignment(x, &emptyInterface, "argument to built-in "+bin.name)
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                return
                        }
                }
@@ -634,7 +634,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        check.updateExprType(a.expr, x.typ_, true)
                }
 
-               if check.recordTypes() && x.mode != constant_ {
+               if check.recordTypes() && x.mode_ != constant_ {
                        types := make([]Type, nargs)
                        for i := range types {
                                types[i] = x.typ_
@@ -648,7 +648,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                arg := argList[0]
                check.exprOrType(x, arg, false)
                check.exclude(x, 1<<novalue|1<<builtin)
-               switch x.mode {
+               switch x.mode_ {
                case invalid:
                        return
                case typexpr:
@@ -659,7 +659,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        if isUntyped(x.typ_) {
                                // check for overflow and untyped nil
                                check.assignment(x, nil, "argument to new")
-                               if x.mode == invalid {
+                               if x.mode_ == invalid {
                                        return
                                }
                                assert(isTyped(x.typ_))
@@ -669,7 +669,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }
 
                T := x.typ_
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewPointer(T)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, T))
@@ -691,11 +691,11 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }
 
                check.assignment(x, &emptyInterface, "argument to panic")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, &emptyInterface))
                }
@@ -708,21 +708,21 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        params = make([]Type, nargs)
                        for i, a := range args {
                                check.assignment(a, nil, "argument to built-in "+predeclaredFuncs[id].name)
-                               if a.mode == invalid {
+                               if a.mode_ == invalid {
                                        return
                                }
                                params[i] = a.typ_
                        }
                }
 
-               x.mode = novalue
+               x.mode_ = novalue
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(nil, params...))
                }
 
        case _Recover:
                // recover() interface{}
-               x.mode = value
+               x.mode_ = value
                x.typ_ = &emptyInterface
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_))
@@ -733,7 +733,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                check.verifyVersionf(call.Fun, go1_17, "unsafe.Add")
 
                check.assignment(x, Typ[UnsafePointer], "argument to unsafe.Add")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
@@ -742,7 +742,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = Typ[UnsafePointer]
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, x.typ_, y.typ_))
@@ -751,17 +751,17 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
        case _Alignof:
                // unsafe.Alignof(x T) uintptr
                check.assignment(x, nil, "argument to unsafe.Alignof")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
                if check.hasVarSize(x.typ_) {
-                       x.mode = value
+                       x.mode_ = value
                        if check.recordTypes() {
                                check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ_))
                        }
                } else {
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.val = constant.MakeInt64(check.conf.alignof(x.typ_))
                        // result is constant - no need to record signature
                }
@@ -779,7 +779,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                }
 
                check.expr(nil, x, selx.X)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
@@ -809,7 +809,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                // record the selector expression (was bug - go.dev/issue/47895)
                {
                        mode := value
-                       if x.mode == variable || indirect {
+                       if x.mode_ == variable || indirect {
                                mode = variable
                        }
                        check.record(&operand{mode, selx, obj.Type(), nil, 0})
@@ -820,7 +820,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                // simpler and also permits (or at least doesn't prevent) a compiler from re-
                // arranging struct fields if it wanted to.
                if check.hasVarSize(base) {
-                       x.mode = value
+                       x.mode_ = value
                        if check.recordTypes() {
                                check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], obj.Type()))
                        }
@@ -830,7 +830,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                                check.errorf(x, TypeTooLarge, "%s is too large", x)
                                return
                        }
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.val = constant.MakeInt64(offs)
                        // result is constant - no need to record signature
                }
@@ -839,12 +839,12 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
        case _Sizeof:
                // unsafe.Sizeof(x T) uintptr
                check.assignment(x, nil, "argument to unsafe.Sizeof")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
                if check.hasVarSize(x.typ_) {
-                       x.mode = value
+                       x.mode_ = value
                        if check.recordTypes() {
                                check.recordBuiltinType(call.Fun, makeSig(Typ[Uintptr], x.typ_))
                        }
@@ -854,7 +854,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                                check.errorf(x, TypeTooLarge, "%s is too large", x)
                                return
                        }
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.val = constant.MakeInt64(size)
                        // result is constant - no need to record signature
                }
@@ -876,7 +876,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewSlice(ptr.base)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, ptr, y.typ_))
@@ -893,7 +893,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewPointer(slice.elem)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, slice))
@@ -904,7 +904,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                check.verifyVersionf(call.Fun, go1_20, "unsafe.String")
 
                check.assignment(x, NewPointer(universeByte), "argument to unsafe.String")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
@@ -913,7 +913,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = Typ[String]
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, NewPointer(universeByte), y.typ_))
@@ -924,11 +924,11 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                check.verifyVersionf(call.Fun, go1_20, "unsafe.StringData")
 
                check.assignment(x, Typ[String], "argument to unsafe.StringData")
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
 
-               x.mode = value
+               x.mode_ = value
                x.typ_ = NewPointer(universeByte)
                if check.recordTypes() {
                        check.recordBuiltinType(call.Fun, makeSig(x.typ_, Typ[String]))
@@ -938,7 +938,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                // 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
                }
@@ -960,7 +960,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                // (no argument evaluated yet)
                if nargs == 0 {
                        check.dump("%v: trace() without arguments", call.Pos())
-                       x.mode = novalue
+                       x.mode_ = novalue
                        break
                }
                var t operand
@@ -970,7 +970,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                        check.dump("%v: %s", x1.Pos(), x1)
                        x1 = &t // use incoming x only for first argument
                }
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
                // trace is only available in test mode - no need to record signature
@@ -979,7 +979,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b
                panic("unreachable")
        }
 
-       assert(x.mode != invalid)
+       assert(x.mode_ != invalid)
        return true
 }
 
index 364800c66cd460d829f11e9a24154455699f4055..3d85e164c876be858d2295e44b8548721a3dacc2 100644 (file)
@@ -50,7 +50,7 @@ func (check *Checker) funcInst(T *target, pos token.Pos, x *operand, ix *indexed
                xlist = ix.indices
                targs = check.typeList(xlist)
                if targs == nil {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return nil
                }
                assert(len(targs) == len(xlist))
@@ -64,7 +64,7 @@ func (check *Checker) funcInst(T *target, pos token.Pos, x *operand, ix *indexed
        if got > want {
                // Providing too many type arguments is always an error.
                check.errorf(ix.indices[got-1], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
-               x.mode = invalid
+               x.mode_ = invalid
                return nil
        }
 
@@ -101,7 +101,7 @@ func (check *Checker) funcInst(T *target, pos token.Pos, x *operand, ix *indexed
                        // that makes sense when reported in error messages from infer, below.
                        expr := ast.NewIdent(T.desc)
                        expr.NamePos = x.Pos() // correct position
-                       args = []*operand{{mode: value, expr: expr, typ_: T.sig}}
+                       args = []*operand{{mode_: value, expr: expr, typ_: T.sig}}
                        reverse = true
                }
 
@@ -115,7 +115,7 @@ func (check *Checker) funcInst(T *target, pos token.Pos, x *operand, ix *indexed
                        if !err.empty() {
                                err.report()
                        }
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return nil
                }
                got = len(targs)
@@ -125,7 +125,7 @@ func (check *Checker) funcInst(T *target, pos token.Pos, x *operand, ix *indexed
        // instantiate function signature
        sig = check.instantiateSignature(x.Pos(), x.expr, sig, targs, xlist)
        x.typ_ = sig
-       x.mode = value
+       x.mode_ = value
        return nil
 }
 
@@ -176,7 +176,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
                        // Delay function instantiation to argument checking,
                        // where we combine type and value arguments for type
                        // inference.
-                       assert(x.mode == value)
+                       assert(x.mode_ == value)
                } else {
                        ix = nil
                }
@@ -187,7 +187,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
        }
        // x.typ may be generic
 
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                check.use(call.Args...)
                x.expr = call
@@ -196,11 +196,11 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
        case typexpr:
                // conversion
                check.nonGeneric(nil, x)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return conversion
                }
                T := x.typ_
-               x.mode = invalid
+               x.mode_ = invalid
                // We cannot convert a value to an incomplete type; make sure it's complete.
                if !check.isComplete(T) {
                        x.expr = call
@@ -211,7 +211,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
                        check.errorf(inNode(call, call.Rparen), WrongArgCount, "missing argument in conversion to %s", T)
                case 1:
                        check.expr(nil, x, call.Args[0])
-                       if x.mode != invalid {
+                       if x.mode_ != invalid {
                                if hasDots(call) {
                                        check.errorf(call.Args[0], BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T)
                                        break
@@ -235,11 +235,11 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
                // no need to check for non-genericity here
                id := x.id
                if !check.builtin(x, call, id) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                }
                x.expr = call
                // a non-constant result implies a function call
-               if x.mode != invalid && x.mode != constant_ {
+               if x.mode_ != invalid && x.mode_ != constant_ {
                        check.hasCallOrRecv = true
                }
                return predeclaredFuncs[id].kind
@@ -247,7 +247,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
 
        // ordinary function/method call
        // signature may be generic
-       cgocall := x.mode == cgofunc
+       cgocall := x.mode_ == cgofunc
 
        // 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.
@@ -259,7 +259,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
        })
        if err != nil {
                check.errorf(x, InvalidCall, invalidOp+"cannot call %s: %s", x, err.format(check))
-               x.mode = invalid
+               x.mode_ = invalid
                x.expr = call
                return statement
        }
@@ -276,7 +276,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
                targs = check.typeList(xlist)
                if targs == nil {
                        check.use(call.Args...)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        x.expr = call
                        return statement
                }
@@ -287,7 +287,7 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
                if got > want {
                        check.errorf(xlist[want], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
                        check.use(call.Args...)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        x.expr = call
                        return statement
                }
@@ -319,23 +319,23 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
        // determine result
        switch sig.results.Len() {
        case 0:
-               x.mode = novalue
+               x.mode_ = novalue
        case 1:
                if cgocall {
-                       x.mode = commaerr
+                       x.mode_ = commaerr
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
                typ := sig.results.vars[0].typ // unpack tuple
                // We cannot return a value of an incomplete type; make sure it's complete.
                if !check.isComplete(typ) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        x.expr = call
                        return statement
                }
                x.typ_ = typ
        default:
-               x.mode = value
+               x.mode_ = value
                x.typ_ = sig.results
        }
        x.expr = call
@@ -343,8 +343,8 @@ func (check *Checker) callExpr(x *operand, call *ast.CallExpr) exprKind {
 
        // 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_) {
-               x.mode = invalid
+       if x.mode_ == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ_) {
+               x.mode_ = invalid
        }
 
        return statement
@@ -419,11 +419,11 @@ func (check *Checker) genericExprList(elist []ast.Expr) (resList []*operand, tar
                        // 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).
@@ -757,27 +757,27 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                        switch exp := exp.(type) {
                        case *Const:
                                assert(exp.Val() != nil)
-                               x.mode = constant_
+                               x.mode_ = constant_
                                x.typ_ = exp.typ
                                x.val = exp.val
                        case *TypeName:
-                               x.mode = typexpr
+                               x.mode_ = typexpr
                                x.typ_ = exp.typ
                        case *Var:
-                               x.mode = variable
+                               x.mode_ = variable
                                x.typ_ = exp.typ
                                if pkg.cgo && strings.HasPrefix(exp.name, "_Cvar_") {
                                        x.typ_ = x.typ_.(*Pointer).base
                                }
                        case *Func:
-                               x.mode = funcMode
+                               x.mode_ = funcMode
                                x.typ_ = exp.typ
                                if pkg.cgo && strings.HasPrefix(exp.name, "_Cmacro_") {
-                                       x.mode = value
+                                       x.mode_ = value
                                        x.typ_ = x.typ_.(*Signature).results.vars[0].typ
                                }
                        case *Builtin:
-                               x.mode = builtin
+                               x.mode_ = builtin
                                x.typ_ = exp.typ
                                x.id = exp.id
                        default:
@@ -790,7 +790,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
        }
 
        check.exprOrType(x, e.X, false)
-       switch x.mode {
+       switch x.mode_ {
        case builtin:
                // types2 uses the position of '.' for the error
                check.errorf(e.Sel, UncalledBuiltin, "invalid use of %s in selector expression", x)
@@ -825,7 +825,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                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()) {
@@ -839,7 +839,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                }
 
                if indirect {
-                       if x.mode == typexpr {
+                       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)
                        } else {
                                check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ_)
@@ -851,7 +851,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                if isInterfacePtr(x.typ_) {
                        why = check.interfacePtrError(x.typ_)
                } else {
-                       alt, _, _ := lookupFieldOrMethod(x.typ_, x.mode == variable, check.pkg, sel, true)
+                       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)
@@ -861,17 +861,17 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
 
        switch obj := obj.(type) {
        case *Var:
-               if x.mode == typexpr {
+               if x.mode_ == typexpr {
                        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)
-               if x.mode == variable || indirect {
-                       x.mode = variable
+               if x.mode_ == variable || indirect {
+                       x.mode_ = variable
                } else {
-                       x.mode = value
+                       x.mode_ = value
                }
                x.typ_ = obj.typ
 
@@ -879,7 +879,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                check.objDecl(obj) // ensure fully set-up signature
                check.addDeclDep(obj)
 
-               if x.mode == typexpr {
+               if x.mode_ == typexpr {
                        // method expression
                        check.recordSelection(e, MethodExpr, x.typ_, obj, index, indirect)
 
@@ -910,7 +910,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                                }
                        }
                        params = append([]*Var{NewParam(sig.recv.pos, sig.recv.pkg, name, x.typ_)}, params...)
-                       x.mode = value
+                       x.mode_ = value
                        x.typ_ = &Signature{
                                tparams:  sig.tparams,
                                params:   NewTuple(params...),
@@ -938,7 +938,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                                // any incomplete interfaces so they are available to NewMethodSet
                                // (which assumes that interfaces have been completed already).
                                typ := x.typ_
-                               if x.mode == variable {
+                               if x.mode_ == variable {
                                        // If typ is not an (unnamed) pointer or an interface,
                                        // use *typ instead, because the method set of *typ
                                        // includes the methods of typ.
@@ -969,7 +969,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
                                }
                        }
 
-                       x.mode = value
+                       x.mode_ = value
 
                        // remove receiver
                        sig := *obj.typ.(*Signature)
@@ -986,7 +986,7 @@ func (check *Checker) selector(x *operand, e *ast.SelectorExpr, wantType bool) {
        return
 
 Error:
-       x.mode = invalid
+       x.mode_ = invalid
        x.typ_ = Typ[Invalid]
        x.expr = e
 }
@@ -1015,7 +1015,7 @@ func (check *Checker) useN(args []ast.Expr, lhs bool) bool {
 
 func (check *Checker) use1(e ast.Expr, lhs bool) bool {
        var x operand
-       x.mode = value // anything but invalid
+       x.mode_ = value // anything but invalid
        switch n := ast.Unparen(e).(type) {
        case nil:
                // nothing to do
@@ -1047,5 +1047,5 @@ func (check *Checker) use1(e ast.Expr, lhs bool) bool {
        default:
                check.rawExpr(nil, &x, e, nil, true)
        }
-       return x.mode != invalid
+       return x.mode_ != invalid
 }
index b210587e8a9f7e13cdc762a9e5b81c52bcdb665b..c8e24428fcb18b837077d470a6e7c89402983f86 100644 (file)
@@ -20,7 +20,7 @@ import (
 // For untyped constants, it checks that the value doesn't become
 // arbitrarily large.
 func (check *Checker) overflow(x *operand, opPos token.Pos) {
-       assert(x.mode == constant_)
+       assert(x.mode_ == constant_)
 
        if x.val.Kind() == constant.Unknown {
                // TODO(gri) We should report exactly what went wrong. At the
@@ -240,7 +240,7 @@ func (check *Checker) representable(x *operand, typ *Basic) {
        v, code := check.representation(x, typ)
        if code != 0 {
                check.invalidConversion(code, x, typ)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
        assert(v != nil)
@@ -252,7 +252,7 @@ func (check *Checker) representable(x *operand, typ *Basic) {
 //
 // If no such representation is possible, it returns a non-zero error code.
 func (check *Checker) representation(x *operand, typ *Basic) (constant.Value, Code) {
-       assert(x.mode == constant_)
+       assert(x.mode_ == constant_)
        v := x.val
        if !representableConst(x.val, check, typ, &v) {
                if isNumeric(x.typ_) && isNumeric(typ) {
@@ -294,7 +294,7 @@ func (check *Checker) convertUntyped(x *operand, target Type) {
                        t = safeUnderlying(target)
                }
                check.invalidConversion(code, x, t)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
        if val != nil {
index a0bf21102439dc608eefe8af0da1798188f272b0..e64a46ff7c0eb2d9f19b179df84b7e07db3bcf91 100644 (file)
@@ -18,7 +18,7 @@ import (
 // conversion type-checks the conversion T(x).
 // The result is in x.
 func (check *Checker) conversion(x *operand, T Type) {
-       constArg := x.mode == constant_
+       constArg := x.mode_ == constant_
 
        constConvertibleTo := func(T Type, val *constant.Value) bool {
                switch t, _ := T.Underlying().(*Basic); {
@@ -50,7 +50,7 @@ func (check *Checker) conversion(x *operand, T Type) {
                // (go.dev/issue/63563)
                if !ok && isInteger(x.typ_) && isInteger(T) {
                        check.errorf(x, InvalidConversion, "constant %s overflows %s", x.val, T)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        case constArg && isTypeParam(T):
@@ -79,11 +79,11 @@ func (check *Checker) conversion(x *operand, T Type) {
                        }
                        return true
                })
-               x.mode = value // type parameters are not constants
+               x.mode_ = value // type parameters are not constants
        case x.convertibleTo(check, T, &cause):
                // non-constant conversion
                ok = true
-               x.mode = value
+               x.mode_ = value
        }
 
        if !ok {
@@ -92,7 +92,7 @@ func (check *Checker) conversion(x *operand, T Type) {
                } else {
                        check.errorf(x, InvalidConversion, "cannot convert %s to type %s", x, T)
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -113,7 +113,7 @@ func (check *Checker) conversion(x *operand, T Type) {
                        // 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) {
+               } else if x.mode_ == constant_ && isInteger(x.typ_) && allString(T) {
                        final = x.typ_
                }
                check.updateExprType(x.expr, final, true)
index e24693f1b68fb2b377edd570fe41a9da73b4bc7d..cc6f0ad309d21ea7e669b3dceb1f1eaed2ddbf30 100644 (file)
@@ -128,7 +128,7 @@ var op2str2 = [...]string{
 // The unary expression e may be nil. It's passed in for better error messages only.
 func (check *Checker) unary(x *operand, e *ast.UnaryExpr) {
        check.expr(nil, x, e.X)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
 
@@ -137,31 +137,31 @@ func (check *Checker) unary(x *operand, e *ast.UnaryExpr) {
        case token.AND:
                // spec: "As an exception to the addressability
                // requirement x may also be a composite literal."
-               if _, ok := ast.Unparen(e.X).(*ast.CompositeLit); !ok && x.mode != variable {
+               if _, ok := ast.Unparen(e.X).(*ast.CompositeLit); !ok && x.mode_ != variable {
                        check.errorf(x, UnaddressableOperand, invalidOp+"cannot take address of %s", x)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = &Pointer{base: x.typ_}
                return
 
        case token.ARROW:
                // 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.mode_ = commaok
                        x.typ_ = elem
                        check.hasCallOrRecv = true
                        return
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
 
        case token.TILDE:
                // Provide a better error position and message than what check.op below would do.
                if !allInteger(x.typ_) {
                        check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint")
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
                check.error(e, UndefinedOp, "cannot use ~ outside of interface or type constraint (use ^ for bitwise complement)")
@@ -169,11 +169,11 @@ func (check *Checker) unary(x *operand, e *ast.UnaryExpr) {
        }
 
        if !check.op(unaryOpPredicates, x, op) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                if x.val.Kind() == constant.Unknown {
                        // nothing to do (and don't cause an error below in the overflow check)
                        return
@@ -188,7 +188,7 @@ func (check *Checker) unary(x *operand, e *ast.UnaryExpr) {
                return
        }
 
-       x.mode = value
+       x.mode_ = value
        // x.typ remains unchanged
 }
 
@@ -362,7 +362,7 @@ func (check *Checker) updateExprType(x ast.Expr, typ Type, final bool) {
                // If x is a constant, it must be representable as a value of typ.
                c := operand{old.mode, x, old.typ, old.val, 0}
                check.convertUntyped(&c, typ)
-               if c.mode == invalid {
+               if c.mode_ == invalid {
                        return
                }
        }
@@ -386,7 +386,7 @@ func (check *Checker) updateExprVal(x ast.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) {
+       if x.mode_ == invalid || isTyped(x.typ_) || !isValid(target) {
                return x.typ_, nil, 0
        }
        // x is untyped
@@ -401,7 +401,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
 
        switch u := target.Underlying().(type) {
        case *Basic:
-               if x.mode == constant_ {
+               if x.mode_ == constant_ {
                        v, code := check.representation(x, u)
                        if code != 0 {
                                return nil, nil, code
@@ -483,7 +483,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const
 func (check *Checker) comparison(x, y *operand, op token.Token, 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_) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -558,12 +558,12 @@ func (check *Checker) comparison(x, y *operand, op token.Token, switchCase bool)
        }
 
        // comparison is ok
-       if x.mode == constant_ && y.mode == constant_ {
+       if x.mode_ == constant_ && y.mode_ == constant_ {
                x.val = constant.MakeBool(constant.Compare(x.val, op, y.val))
                // The operands are never materialized; no need to update
                // their types.
        } else {
-               x.mode = value
+               x.mode_ = value
                // The operands have now their final types, which at run-
                // time will be materialized. Update the expression trees.
                // If the current types are untyped, the materialized type
@@ -600,7 +600,7 @@ Error:
        } else {
                check.errorf(errOp, code, invalidOp+"%s %s %s (%s)", x.expr, op, y.expr, cause)
        }
-       x.mode = invalid
+       x.mode_ = invalid
 }
 
 // incomparableCause returns a more specific cause why typ is not comparable.
@@ -619,7 +619,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
        // TODO(gri) This function seems overly complex. Revisit.
 
        var xval constant.Value
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                xval = constant.ToInt(x.val)
        }
 
@@ -629,7 +629,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
        } else {
                // shift has no chance
                check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -639,12 +639,12 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
        // Check that constants are representable by uint, but do not convert them
        // (see also go.dev/issue/47243).
        var yval constant.Value
-       if y.mode == constant_ {
+       if y.mode_ == constant_ {
                // Provide a good error message for negative shift counts.
                yval = constant.ToInt(y.val) // consider -1, 1.0, but not -1.1
                if yval.Kind() == constant.Int && constant.Sign(yval) < 0 {
                        check.errorf(y, InvalidShiftCount, invalidOp+"negative shift count %s", y)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
 
@@ -652,8 +652,8 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
                        // 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])
-                       if y.mode == invalid {
-                               x.mode = invalid
+                       if y.mode_ == invalid {
+                               x.mode_ = invalid
                                return
                        }
                }
@@ -662,26 +662,26 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
                switch {
                case allInteger(y.typ_):
                        if !allUnsigned(y.typ_) && !check.verifyVersionf(y, go1_13, invalidOp+"signed shift count %s", y) {
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                case isUntyped(y.typ_):
                        // This is incorrect, but preserves pre-existing behavior.
                        // See also go.dev/issue/47410.
                        check.convertUntyped(y, Typ[Uint])
-                       if y.mode == invalid {
-                               x.mode = invalid
+                       if y.mode_ == invalid {
+                               x.mode_ = invalid
                                return
                        }
                default:
                        check.errorf(y, InvalidShiftCount, invalidOp+"shift count %s must be integer", y)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        }
 
-       if x.mode == constant_ {
-               if y.mode == constant_ {
+       if x.mode_ == constant_ {
+               if y.mode_ == constant_ {
                        // if either x or y has an unknown value, the result is unknown
                        if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown {
                                x.val = constant.MakeUnknown()
@@ -696,7 +696,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
                        s, ok := constant.Uint64Val(yval)
                        if !ok || s > shiftBound {
                                check.errorf(y, InvalidShiftCount, invalidOp+"invalid shift count %s", y)
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                        // The lhs is representable as an integer but may not be an integer
@@ -739,7 +739,7 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
                                check.untyped[x.expr] = info
                        }
                        // keep x's type
-                       x.mode = value
+                       x.mode_ = value
                        return
                }
        }
@@ -747,11 +747,11 @@ func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
        // non-constant shift - lhs must be an integer
        if !allInteger(x.typ_) {
                check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
-       x.mode = value
+       x.mode_ = value
 }
 
 var binaryOpPredicates opPredicates
@@ -783,11 +783,11 @@ func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token
        check.expr(nil, x, lhs)
        check.expr(nil, &y, rhs)
 
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
-       if y.mode == invalid {
-               x.mode = invalid
+       if y.mode_ == invalid {
+               x.mode_ = invalid
                x.expr = y.expr
                return
        }
@@ -798,7 +798,7 @@ func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token
        }
 
        check.matchTypes(x, &y)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return
        }
 
@@ -821,36 +821,36 @@ func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token
                                check.errorf(posn, MismatchedTypes, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ_, y.typ_)
                        }
                }
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
        if !check.op(binaryOpPredicates, x, op) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
        if op == token.QUO || op == token.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
+                       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 {
                                check.error(&y, DivByZero, invalidOp+"division by zero")
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                }
        }
 
-       if x.mode == constant_ && y.mode == constant_ {
+       if x.mode_ == constant_ && y.mode_ == constant_ {
                // if either x or y has an unknown value, the result is unknown
                if x.val.Kind() == constant.Unknown || y.val.Kind() == constant.Unknown {
                        x.val = constant.MakeUnknown()
@@ -867,7 +867,7 @@ func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token
                return
        }
 
-       x.mode = value
+       x.mode_ = value
        // x.typ is unchanged
 }
 
@@ -924,12 +924,12 @@ func (check *Checker) matchTypes(x, y *operand) {
 
        if mayConvert(x, y) {
                check.convertUntyped(x, y.typ_)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
                check.convertUntyped(y, x.typ_)
-               if y.mode == invalid {
-                       x.mode = invalid
+               if y.mode_ == invalid {
+                       x.mode_ = invalid
                        return
                }
        }
@@ -995,7 +995,7 @@ func (check *Checker) rawExpr(T *target, x *operand, e ast.Expr, hint Type, allo
 // from a non-nil target T, nonGeneric reports an error and invalidates x.mode and x.typ.
 // Otherwise it leaves x alone.
 func (check *Checker) nonGeneric(T *target, x *operand) {
-       if x.mode == invalid || x.mode == novalue {
+       if x.mode_ == invalid || x.mode_ == novalue {
                return
        }
        var what string
@@ -1015,7 +1015,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.mode_ = invalid
                x.typ_ = Typ[Invalid]
        }
 }
@@ -1026,7 +1026,7 @@ func (check *Checker) nonGeneric(T *target, x *operand) {
 func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type) exprKind {
        // make sure x has a valid state in case of bailout
        // (was go.dev/issue/5770)
-       x.mode = invalid
+       x.mode_ = invalid
        x.typ_ = Typ[Invalid]
 
        switch e := e.(type) {
@@ -1043,19 +1043,19 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
 
        case *ast.BasicLit:
                check.basicLit(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *ast.FuncLit:
                check.funcLit(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *ast.CompositeLit:
                check.compositeLit(x, e, hint)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
@@ -1076,19 +1076,19 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
                        }
                        check.funcInst(T, e.Pos(), x, ix, true)
                }
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *ast.SliceExpr:
                check.sliceExpr(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
        case *ast.TypeAssertExpr:
                check.expr(nil, x, e.X)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
                // x.(type) expressions are handled explicitly in type switches
@@ -1115,7 +1115,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
                        goto Error
                }
                check.typeAssertion(e, x, T, false)
-               x.mode = commaok
+               x.mode_ = commaok
                x.typ_ = T
 
        case *ast.CallExpr:
@@ -1123,7 +1123,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
 
        case *ast.StarExpr:
                check.exprOrType(x, e.X, false)
-               switch x.mode {
+               switch x.mode_ {
                case invalid:
                        goto Error
                case typexpr:
@@ -1150,13 +1150,13 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
                        if !check.isComplete(base) {
                                goto Error
                        }
-                       x.mode = variable
+                       x.mode_ = variable
                        x.typ_ = base
                }
 
        case *ast.UnaryExpr:
                check.unary(x, e)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
                if e.Op == token.ARROW {
@@ -1166,7 +1166,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
 
        case *ast.BinaryExpr:
                check.binary(x, e, e.X, e.Y, e.Op, e.OpPos)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        goto Error
                }
 
@@ -1177,7 +1177,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
 
        case *ast.ArrayType, *ast.StructType, *ast.FuncType,
                *ast.InterfaceType, *ast.MapType, *ast.ChanType:
-               x.mode = typexpr
+               x.mode_ = typexpr
                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
@@ -1194,7 +1194,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type)
        return expression
 
 Error:
-       x.mode = invalid
+       x.mode_ = invalid
        x.expr = e
        return statement // avoid follow-up errors
 }
@@ -1284,20 +1284,20 @@ func (check *Checker) multiExpr(e ast.Expr, allowCommaOk bool) (list []*operand,
        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
        }
 
        // 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]}
-               if x.mode == commaerr {
+       if allowCommaOk && (x.mode_ == mapindex || x.mode_ == commaok || x.mode_ == commaerr) {
+               x2 := &operand{mode_: value, expr: e, typ_: Typ[UntypedBool]}
+               if x.mode_ == commaerr {
                        x2.typ_ = universeError
                }
                list = append(list, x2)
@@ -1330,10 +1330,10 @@ func (check *Checker) exprOrType(x *operand, e ast.Expr, allowGeneric bool) {
 // exclude reports an error if x.mode is in modeset and sets x.mode to invalid.
 // The modeset may contain any of 1<<novalue, 1<<builtin, 1<<typexpr.
 func (check *Checker) exclude(x *operand, modeset uint) {
-       if modeset&(1<<x.mode) != 0 {
+       if modeset&(1<<x.mode_) != 0 {
                var msg string
                var code Code
-               switch x.mode {
+               switch x.mode_ {
                case novalue:
                        if modeset&(1<<typexpr) != 0 {
                                msg = "%s used as value"
@@ -1351,18 +1351,18 @@ func (check *Checker) exclude(x *operand, modeset uint) {
                        panic("unreachable")
                }
                check.errorf(x, code, msg, x)
-               x.mode = invalid
+               x.mode_ = invalid
        }
 }
 
 // singleValue reports an error if x describes a tuple and sets x.mode to invalid.
 func (check *Checker) singleValue(x *operand) {
-       if x.mode == value {
+       if x.mode_ == value {
                // tuple types are never named - no need for underlying type below
                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
+                       x.mode_ = invalid
                }
        }
 }
index a065eb19b0ffa64f241d480493d2a4464ef42293..711c88a540fdc60b4723610cdabbe5c7c75bab4d 100644 (file)
@@ -20,18 +20,18 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
        check.exprOrType(x, e.x, true)
        // x may be generic
 
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                check.use(e.indices...)
                return false
 
        case typexpr:
                // type instantiation
-               x.mode = invalid
+               x.mode_ = invalid
                // TODO(gri) here we re-evaluate e.X - try to avoid this
                x.typ_ = check.varType(e.orig)
                if isValid(x.typ_) {
-                       x.mode = typexpr
+                       x.mode_ = typexpr
                }
                return false
 
@@ -44,13 +44,13 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
 
        // x should not be generic at this point, but be safe and check
        check.nonGeneric(nil, x)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return false
        }
 
        // We cannot index on an incomplete type; make sure it's complete.
        if !check.isComplete(x.typ_) {
-               x.mode = invalid
+               x.mode_ = invalid
                return false
        }
        switch typ := x.typ_.Underlying().(type) {
@@ -58,14 +58,14 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
                // Additionally, if x.typ is a pointer to an array type, indexing implicitly dereferences the value, meaning
                // its base type must also be complete.
                if !check.isComplete(typ.base) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return false
                }
        case *Map:
                // Lastly, if x.typ is a map type, indexing must produce a value of a complete type, meaning
                // its element type must also be complete.
                if !check.isComplete(typ.elem) {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return false
                }
        }
@@ -77,21 +77,21 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
        case *Basic:
                if isString(typ) {
                        valid = true
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                length = int64(len(constant.StringVal(x.val)))
                        }
                        // an indexed string always yields a byte value
                        // (not a constant) even if the string and the
                        // index are constant
-                       x.mode = value
+                       x.mode_ = value
                        x.typ_ = universeByte // use 'byte' name
                }
 
        case *Array:
                valid = true
                length = typ.len
-               if x.mode != variable {
-                       x.mode = value
+               if x.mode_ != variable {
+                       x.mode_ = value
                }
                x.typ_ = typ.elem
 
@@ -99,26 +99,26 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
                if typ, _ := typ.base.Underlying().(*Array); typ != nil {
                        valid = true
                        length = typ.len
-                       x.mode = variable
+                       x.mode_ = variable
                        x.typ_ = typ.elem
                }
 
        case *Slice:
                valid = true
-               x.mode = variable
+               x.mode_ = variable
                x.typ_ = typ.elem
 
        case *Map:
                index := check.singleIndex(e)
                if index == nil {
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return false
                }
                var key operand
                check.expr(nil, &key, index)
                check.assignment(&key, typ.key, "map index")
                // ok to continue even if indexing failed - map element type is known
-               x.mode = mapindex
+               x.mode_ = mapindex
                x.typ_ = typ.elem
                x.expr = e.orig
                return false
@@ -143,7 +143,7 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
                        case *Array:
                                l = t.len
                                e = t.elem
-                               if x.mode != variable {
+                               if x.mode_ != variable {
                                        mode = value
                                }
                        case *Pointer:
@@ -185,14 +185,14 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
                        if key != nil {
                                index := check.singleIndex(e)
                                if index == nil {
-                                       x.mode = invalid
+                                       x.mode_ = invalid
                                        return false
                                }
                                var k operand
                                check.expr(nil, &k, index)
                                check.assignment(&k, key, "map index")
                                // ok to continue even if indexing failed - map element type is known
-                               x.mode = mapindex
+                               x.mode_ = mapindex
                                x.typ_ = elem
                                x.expr = e.orig
                                return false
@@ -200,7 +200,7 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
 
                        // no maps
                        valid = true
-                       x.mode = mode
+                       x.mode_ = mode
                        x.typ_ = elem
                }
        }
@@ -209,13 +209,13 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
                // types2 uses the position of '[' for the error
                check.errorf(x, NonIndexableOperand, "cannot index %s", x)
                check.use(e.indices...)
-               x.mode = invalid
+               x.mode_ = invalid
                return false
        }
 
        index := check.singleIndex(e)
        if index == nil {
-               x.mode = invalid
+               x.mode_ = invalid
                return false
        }
 
@@ -232,7 +232,7 @@ func (check *Checker) indexExpr(x *operand, e *indexedExpr) (isFuncInst bool) {
 
 func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
        check.expr(nil, x, e.X)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                check.use(e.Low, e.High, e.Max)
                return
        }
@@ -282,7 +282,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
        // 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) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -291,7 +291,7 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
        switch u := cu.(type) {
        case nil:
                // error reported above
-               x.mode = invalid
+               x.mode_ = invalid
                return
 
        case *Basic:
@@ -302,11 +302,11 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
                                        at = e // e.Index[2] should be present but be careful
                                }
                                check.error(at, InvalidSliceExpr, invalidOp+"3-index slice of string")
-                               x.mode = invalid
+                               x.mode_ = invalid
                                return
                        }
                        valid = true
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                length = int64(len(constant.StringVal(x.val)))
                        }
                        // spec: "For untyped string operands the result
@@ -319,9 +319,9 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
        case *Array:
                valid = true
                length = u.len
-               if x.mode != variable {
+               if x.mode_ != variable {
                        check.errorf(x, NonSliceableOperand, "cannot slice unaddressable value %s", x)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
                x.typ_ = &Slice{elem: u.elem}
@@ -340,16 +340,16 @@ func (check *Checker) sliceExpr(x *operand, e *ast.SliceExpr) {
 
        if !valid {
                check.errorf(x, NonSliceableOperand, "cannot slice %s", x)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
-       x.mode = value
+       x.mode_ = value
 
        // spec: "Only the first index may be omitted; it defaults to 0."
        if e.Slice3 && (e.High == nil || e.Max == nil) {
                check.error(inNode(e, e.Rbrack), InvalidSyntaxTree, "2nd and 3rd index required in 3-index slice")
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -427,7 +427,7 @@ func (check *Checker) index(index ast.Expr, max int64) (typ Type, val int64) {
                return
        }
 
-       if x.mode != constant_ {
+       if x.mode_ != constant_ {
                return x.typ_, -1
        }
 
@@ -447,13 +447,13 @@ func (check *Checker) index(index ast.Expr, max int64) (typ Type, val int64) {
 }
 
 func (check *Checker) isValidIndex(x *operand, code Code, what string, allowNegative bool) bool {
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return false
        }
 
        // spec: "a constant index that is untyped is given type int"
        check.convertUntyped(x, Typ[Int])
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                return false
        }
 
@@ -463,7 +463,7 @@ func (check *Checker) isValidIndex(x *operand, code Code, what string, allowNega
                return false
        }
 
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                // spec: "a constant index must be non-negative ..."
                if !allowNegative && constant.Sign(x.val) < 0 {
                        check.errorf(x, code, invalidArg+"%s %s must not be negative", what, x)
index 9f63c1f81171cf28020f06ae5b7ba9005b8b9904..2570ea8cab94e069ea397b305c8d0204cc88e801 100644 (file)
@@ -65,7 +65,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type,
        // If we have invalid (ordinary) arguments, an error was reported before.
        // Avoid additional inference errors and exit early (go.dev/issue/60434).
        for _, arg := range args {
-               if arg.mode == invalid {
+               if arg.mode_ == invalid {
                        return nil
                }
        }
@@ -165,7 +165,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type,
        }
 
        for i, arg := range args {
-               if arg.mode == invalid {
+               if arg.mode_ == invalid {
                        // An error was reported earlier. Ignore this arg
                        // and continue, we may still be able to infer all
                        // targs resulting in fewer follow-on errors.
index cf230242ee1c35d730c18ec247316a9b26b6d137..f6d79c299bf59a11e34e13966729396d575bc827 100644 (file)
@@ -61,18 +61,18 @@ func (check *Checker) basicLit(x *operand, e *ast.BasicLit) {
                const limit = 10000
                if len(e.Value) > limit {
                        check.errorf(e, InvalidConstVal, "excessively long constant: %s... (%d chars)", e.Value[:10], len(e.Value))
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        }
        x.setConst(e.Kind, e.Value)
-       if x.mode == invalid {
+       if x.mode_ == invalid {
                // The parser already establishes syntactic correctness.
                // If we reach here it's because of number under-/overflow.
                // TODO(gri) setConst (and in turn the go/constant package)
                // should return an error describing the issue.
                check.errorf(e, InvalidConstVal, "malformed constant: %s", e.Value)
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
        // Ensure that integer values don't overflow (go.dev/issue/54280).
@@ -100,11 +100,11 @@ func (check *Checker) funcLit(x *operand, e *ast.FuncLit) {
                                check.funcBody(decl, "<function literal>", sig, e.Body, iota)
                        }).describef(e, "func literal")
                }
-               x.mode = value
+               x.mode_ = value
                x.typ_ = sig
        } else {
                check.errorf(e, InvalidSyntaxTree, "invalid function literal %v", e)
-               x.mode = invalid
+               x.mode_ = invalid
        }
 }
 
@@ -149,7 +149,7 @@ func (check *Checker) compositeLit(x *operand, e *ast.CompositeLit, hint Type) {
 
        // We cannot create a literal of an incomplete type; make sure it's complete.
        if !check.isComplete(base) {
-               x.mode = invalid
+               x.mode_ = invalid
                return
        }
 
@@ -265,10 +265,10 @@ func (check *Checker) compositeLit(x *operand, e *ast.CompositeLit, hint Type) {
                        }
                        check.exprWithHint(x, kv.Key, utyp.key)
                        check.assignment(x, utyp.key, "map literal")
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                continue
                        }
-                       if x.mode == constant_ {
+                       if x.mode_ == constant_ {
                                duplicate := false
                                xkey := keyVal(x.val)
                                if keyIsInterface {
@@ -315,12 +315,12 @@ func (check *Checker) compositeLit(x *operand, e *ast.CompositeLit, hint Type) {
                                cause = " (no common underlying type)"
                        }
                        check.errorf(e, InvalidLit, "invalid composite literal%s type %s%s", qualifier, typ, cause)
-                       x.mode = invalid
+                       x.mode_ = invalid
                        return
                }
        }
 
-       x.mode = value
+       x.mode_ = value
        x.typ_ = typ
 }
 
index 330d9a42b6a1f6cff851eb901c16ead40e88e863..db525ff10edec44c27d3d0c7e713789aae4e64b2 100644 (file)
@@ -57,11 +57,11 @@ var operandModeString = [...]string{
 // for built-in functions.
 // The zero value of operand is a ready to use invalid operand.
 type operand struct {
-       mode operandMode
-       expr ast.Expr
-       typ_ Type
-       val  constant.Value
-       id   builtinId
+       mode_ operandMode
+       expr  ast.Expr
+       typ_  Type
+       val   constant.Value
+       id    builtinId
 }
 
 // Pos returns the position of the expression corresponding to x.
@@ -113,7 +113,7 @@ func (x *operand) Pos() token.Pos {
 func operandString(x *operand, qf Qualifier) string {
        // special-case nil
        if isTypes2 {
-               if x.mode == nilvalue {
+               if x.mode_ == nilvalue {
                        switch x.typ_ {
                        case nil, Typ[Invalid]:
                                return "nil (with invalid type)"
@@ -124,7 +124,7 @@ func operandString(x *operand, qf Qualifier) string {
                        }
                }
        } 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 {
        if x.expr != nil {
                expr = ExprString(x.expr)
        } else {
-               switch x.mode {
+               switch x.mode_ {
                case builtin:
                        expr = predeclaredFuncs[x.id].name
                case typexpr:
@@ -153,7 +153,7 @@ func operandString(x *operand, qf Qualifier) string {
 
        // <untyped kind>
        hasType := false
-       switch x.mode {
+       switch x.mode_ {
        case invalid, novalue, builtin, typexpr:
                // no type
        default:
@@ -169,10 +169,10 @@ func operandString(x *operand, qf Qualifier) string {
        }
 
        // <mode>
-       buf.WriteString(operandModeString[x.mode])
+       buf.WriteString(operandModeString[x.mode_])
 
        // <val>
-       if x.mode == constant_ {
+       if x.mode_ == constant_ {
                if s := x.val.String(); s != expr {
                        buf.WriteByte(' ')
                        buf.WriteString(s)
@@ -285,11 +285,11 @@ func (x *operand) setConst(k token.Token, lit string) {
 
        val := makeFromLiteral(lit, k)
        if val.Kind() == constant.Unknown {
-               x.mode = invalid
+               x.mode_ = invalid
                x.typ_ = Typ[Invalid]
                return
        }
-       x.mode = constant_
+       x.mode_ = constant_
        x.typ_ = Typ[kind]
        x.val = val
 }
@@ -297,9 +297,9 @@ func (x *operand) setConst(k token.Token, lit string) {
 // isNil reports whether x is the (untyped) nil value.
 func (x *operand) isNil() bool {
        if isTypes2 {
-               return x.mode == nilvalue
+               return x.mode_ == nilvalue
        } else { // go/types
-               return x.mode == value && x.typ_ == Typ[UntypedNil]
+               return x.mode_ == value && x.typ_ == Typ[UntypedNil]
        }
 }
 
@@ -310,7 +310,7 @@ func (x *operand) isNil() bool {
 // if assignableTo is invoked through an exported API call, i.e., when all
 // methods have been type-checked.
 func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Code) {
-       if x.mode == invalid || !isValid(T) {
+       if x.mode_ == invalid || !isValid(T) {
                return true, 0 // avoid spurious errors
        }
 
index 2d160326432cf198af90d06a72d59d5e2d43b071..59a529a65a0a3835b56a345cb1ddc8a65dc39a3d 100644 (file)
@@ -37,7 +37,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *ast.RangeStmt, noN
        check.hasCallOrRecv = false
        check.expr(nil, &x, rangeVar)
 
-       if isTypes2 && x.mode != invalid && sValue == nil && !check.hasCallOrRecv {
+       if isTypes2 && x.mode_ != invalid && sValue == nil && !check.hasCallOrRecv {
                if t, ok := arrayPtrDeref(x.typ_.Underlying()).(*Array); ok {
                        for {
                                // Put constant info on the thing inside parentheses.
@@ -53,18 +53,18 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *ast.RangeStmt, noN
                        // (and thus side-effects will not be computed
                        // by the backend).
                        check.record(&operand{
-                               mode: constant_,
-                               expr: rangeVar,
-                               typ_: Typ[Int],
-                               val:  constant.MakeInt64(t.len),
-                               id:   x.id,
+                               mode_: constant_,
+                               expr:  rangeVar,
+                               typ_:  Typ[Int],
+                               val:   constant.MakeInt64(t.len),
+                               id:    x.id,
                        })
                }
        }
 
        // determine key/value types
        var key, val Type
-       if x.mode != invalid {
+       if x.mode_ != invalid {
                k, v, cause, ok := rangeKeyVal(check, x.typ_, func(v goVersion) bool {
                        return check.allowVersion(v)
                })
@@ -136,7 +136,7 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *ast.RangeStmt, noN
                                check.initVar(obj, &x, "range clause")
                        } else {
                                var y operand
-                               y.mode = value
+                               y.mode_ = value
                                y.expr = lhs // we don't have a better rhs expression to use here
                                y.typ_ = typ
                                check.initVar(obj, &y, "assignment") // error is on variable, use "assignment" not "range clause"
@@ -172,12 +172,12 @@ func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *ast.RangeStmt, noN
                                // 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_) {
+                               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.mode_ = value
                                y.expr = lhs // we don't have a better rhs expression to use here
                                y.typ_ = typ
                                check.assignVar(lhs, nil, &y, "assignment") // error is on variable, use "assignment" not "range clause"
index 5709ce980a93c102069a9caae6684f257611bdd9..570839ac8a51e49158698b4eff7e9f89366b318b 100644 (file)
@@ -20,7 +20,7 @@ func (check *Checker) record(x *operand) {
        // TODO(gri) this code can be simplified
        var typ Type
        var val constant.Value
-       switch x.mode {
+       switch x.mode_ {
        case invalid:
                typ = Typ[Invalid]
        case novalue:
@@ -36,9 +36,9 @@ func (check *Checker) record(x *operand) {
        if isUntyped(typ) {
                // delay type and value recording until we know the type
                // or until the end of type checking
-               check.rememberUntyped(x.expr, false, x.mode, typ.(*Basic), val)
+               check.rememberUntyped(x.expr, false, x.mode_, typ.(*Basic), val)
        } else {
-               check.recordTypeAndValue(x.expr, x.mode, typ, val)
+               check.recordTypeAndValue(x.expr, x.mode_, typ, val)
        }
 }
 
@@ -97,7 +97,7 @@ func (check *Checker) recordBuiltinType(f ast.Expr, sig *Signature) {
 func (check *Checker) recordCommaOkTypes(x ast.Expr, a []*operand) {
        assert(x != nil)
        assert(len(a) == 2)
-       if a[0].mode == invalid {
+       if a[0].mode_ == invalid {
                return
        }
        t0, t1 := a[0].typ_, a[1].typ_
index bc97c8ed45d16f86d0bbcb631d13f73c0cf43ea5..6db1e70dad86d210a3a27fcfe709a2b6bce8790b 100644 (file)
@@ -239,20 +239,20 @@ L:
        for _, e := range values {
                var v operand
                check.expr(nil, &v, e)
-               if x.mode == invalid || v.mode == invalid {
+               if x.mode_ == invalid || v.mode_ == invalid {
                        continue L
                }
                check.convertUntyped(&v, x.typ_)
-               if v.mode == invalid {
+               if v.mode_ == invalid {
                        continue L
                }
                // Order matters: By comparing v against x, error positions are at the case values.
                res := v // keep original v unchanged
                check.comparison(&res, x, token.EQL, true)
-               if res.mode == invalid {
+               if res.mode_ == invalid {
                        continue L
                }
-               if v.mode != constant_ {
+               if v.mode_ != constant_ {
                        continue L // we're done
                }
                // look for duplicate values
@@ -445,7 +445,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
                kind := check.rawExpr(nil, &x, s.X, nil, false)
                var msg string
                var code Code
-               switch x.mode {
+               switch x.mode_ {
                default:
                        if kind == statement {
                                return
@@ -465,7 +465,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
                var ch, val operand
                check.expr(nil, &ch, s.Chan)
                check.expr(nil, &val, s.Value)
-               if ch.mode == invalid || val.mode == invalid {
+               if ch.mode_ == invalid || val.mode_ == invalid {
                        return
                }
                if elem := check.chanElem(inNode(s, s.Arrow), &ch, false); elem != nil {
@@ -486,7 +486,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
 
                var x operand
                check.expr(nil, &x, s.X)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
                if !allNumeric(x.typ_) {
@@ -496,7 +496,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
 
                Y := &ast.BasicLit{ValuePos: s.X.Pos(), Kind: token.INT, Value: "1"} // use x's position
                check.binary(&x, nil, s.X, Y, op, s.TokPos)
-               if x.mode == invalid {
+               if x.mode_ == invalid {
                        return
                }
                check.assignVar(s.X, nil, &x, "assignment")
@@ -528,7 +528,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
                        }
                        var x operand
                        check.binary(&x, nil, s.Lhs[0], s.Rhs[0], op, s.TokPos)
-                       if x.mode == invalid {
+                       if x.mode_ == invalid {
                                return
                        }
                        check.assignVar(s.Lhs[0], nil, &x, "assignment")
@@ -609,7 +609,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.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.Body)
@@ -636,14 +636,14 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
                        // 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_) {
+                       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
+                               x.mode_ = invalid
                        }
                } else {
                        // spec: "A missing switch expression is
                        // equivalent to the boolean value true."
-                       x.mode = constant_
+                       x.mode_ = constant_
                        x.typ_ = Typ[Bool]
                        x.val = constant.MakeBool(true)
                        x.expr = &ast.Ident{NamePos: s.Body.Lbrace, Name: "true"}
@@ -728,7 +728,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) {
                {
                        var x operand
                        check.expr(nil, &x, expr.X)
-                       if x.mode != invalid {
+                       if x.mode_ != invalid {
                                if isTypeParam(x.typ_) {
                                        check.errorf(&x, InvalidTypeSwitch, "cannot use type switch on type parameter value %s", &x)
                                } else if IsInterface(x.typ_) {
@@ -837,7 +837,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.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")
                        }
                }
index 0fed2f65979faeec5f957a6e0f153ec240610b6e..654a731493ca6feed26e46f77d529e899fd64fe4 100644 (file)
@@ -18,7 +18,7 @@ import (
 // If an error occurred, x.mode is set to invalid.
 // If wantType is set, the identifier e is expected to denote a type.
 func (check *Checker) ident(x *operand, e *ast.Ident, wantType bool) {
-       x.mode = invalid
+       x.mode_ = invalid
        x.expr = e
 
        scope, obj := check.lookupScope(e.Name)
@@ -98,10 +98,10 @@ func (check *Checker) ident(x *operand, e *ast.Ident, wantType bool) {
                        x.val = obj.val
                }
                assert(x.val != nil)
-               x.mode = constant_
+               x.mode_ = constant_
 
        case *TypeName:
-               x.mode = typexpr
+               x.mode_ = typexpr
 
        case *Var:
                // It's ok to mark non-local variables, but ignore variables
@@ -114,18 +114,18 @@ func (check *Checker) ident(x *operand, e *ast.Ident, wantType bool) {
                if !isValid(typ) {
                        return
                }
-               x.mode = variable
+               x.mode_ = variable
 
        case *Func:
                check.addDeclDep(obj)
-               x.mode = value
+               x.mode_ = value
 
        case *Builtin:
                x.id = obj.id
-               x.mode = builtin
+               x.mode_ = builtin
 
        case *Nil:
-               x.mode = value
+               x.mode_ = value
 
        default:
                panic("unreachable")
@@ -246,7 +246,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *TypeName) (T Type) {
                var x operand
                check.ident(&x, e, true)
 
-               switch x.mode {
+               switch x.mode_ {
                case typexpr:
                        return x.typ_
                case invalid:
@@ -261,7 +261,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *TypeName) (T Type) {
                var x operand
                check.selector(&x, e, true)
 
-               switch x.mode {
+               switch x.mode_ {
                case typexpr:
                        return x.typ_
                case invalid:
@@ -478,8 +478,8 @@ func (check *Checker) arrayLength(e ast.Expr) int64 {
 
        var x operand
        check.expr(nil, &x, e)
-       if x.mode != constant_ {
-               if x.mode != invalid {
+       if x.mode_ != constant_ {
+               if x.mode_ != invalid {
                        check.errorf(&x, InvalidArrayLen, "array length %s must be constant", &x)
                }
                return -1