Update go version

This commit is contained in:
dwrz
2026-08-21 10:23:37 +00:00
parent 78248a6145
commit c2e2d9ea02
466 changed files with 67766 additions and 2881 deletions

View File

@@ -16,6 +16,8 @@ import (
"os"
"slices"
"strings"
"golang.org/x/tools/internal/typeparams"
)
type sanity struct {
@@ -154,12 +156,17 @@ func (s *sanity) checkInstr(idx int, instr Instruction) {
case *Lookup:
case *MakeChan:
case *MakeClosure:
numFree := len(instr.Fn.(*Function).FreeVars)
numBind := len(instr.Bindings)
if numFree != numBind {
fn := instr.Fn.(*Function)
if numFree, numBind := len(fn.FreeVars), len(instr.Bindings); numFree != numBind {
s.errorf("MakeClosure has %d Bindings for function %s with %d free vars",
numBind, instr.Fn, numFree)
} else {
for i, fv := range fn.FreeVars {
if !types.Identical(instr.Bindings[i].Type(), fv.Type()) {
s.errorf("MakeClosure binding %d for %s has type %s, expected %s",
i, fv.Name(), instr.Bindings[i].Type(), fv.Type())
}
}
}
if recv := instr.Type().(*types.Signature).Recv(); recv != nil {
s.errorf("MakeClosure's type includes receiver %s", recv.Type())
@@ -170,12 +177,42 @@ func (s *sanity) checkInstr(idx int, instr Instruction) {
case *MakeSlice:
case *MapUpdate:
case *Next:
rng, ok := instr.Iter.(*Range)
if !ok {
s.errorf("Next: Iter is %T, not *Range", instr.Iter)
}
if rng.Type() != tRangeIter {
s.errorf("Next: Iter has type %s, expected %s", rng.Type(), tRangeIter)
}
var ek, ev types.Type
switch xt := typeparams.CoreType(rng.X.Type()).(type) {
case *types.Basic:
if types.Default(xt) != tString {
s.errorf("Next: basic operand of Next.Iter (Range) is %s, want string or untyped string", xt)
}
ek, ev = tInt, tRune
case *types.Map:
ek, ev = xt.Key(), xt.Elem()
}
res := instr.Type().(*types.Tuple) // (ok bool, k K, v V), but K or V may be invalid if unused
if !types.Identical(res.At(1).Type(), ek) && res.At(1).Type() != tInvalid {
s.errorf("Next: key type %s does not match map key type %s", res.At(1).Type(), ek)
}
if !types.Identical(res.At(2).Type(), ev) && res.At(2).Type() != tInvalid {
s.errorf("Next: value type %s does not match map value type %s", res.At(2).Type(), ev)
}
case *Range:
case *RunDefers:
case *Select:
case *Send:
case *Slice:
case *Store:
if !types.Identical(instr.Val.Type(), typeparams.CoreType(instr.Addr.Type()).(*types.Pointer).Elem()) {
s.errorf("Store: value type %s does not match address type %s",
instr.Val.Type(), instr.Addr.Type())
}
case *TypeAssert:
case *UnOp:
case *DebugRef:
@@ -417,7 +454,7 @@ func (s *sanity) checkFunctionParams() {
}
if !types.Identical(sigType, param.Type()) {
s.errorf("expect type %s in signature but got type %s in param %d", param.Type(), sigType, i)
s.errorf("expect type %s in signature but got type %s in param %d", sigType, param.Type(), i)
}
}
}
@@ -492,16 +529,16 @@ func (s *sanity) checkFunction(fn *Function) bool {
strings.HasSuffix(fn.name, "Error") ||
strings.HasPrefix(fn.Synthetic, "instance ") ||
strings.HasPrefix(fn.Synthetic, "instantiation ") ||
(fn.parent != nil && len(fn.typeargs) > 0) /* anon fun in instance */ {
fn.parent != nil && fn.parent.hasTypeArgs() /* anon fun in instance */ {
// ok
} else {
s.errorf("nil Pkg")
}
}
if src, syn := fn.Synthetic == "", fn.Syntax() != nil; src != syn {
if len(fn.typeargs) > 0 && fn.Prog.mode&InstantiateGenerics != 0 {
if fn.hasTypeArgs() && fn.Prog.mode&InstantiateGenerics != 0 {
// ok (instantiation with InstantiateGenerics on)
} else if fn.topLevelOrigin != nil && len(fn.typeargs) > 0 {
} else if fn.hasTypeArgs() && fn.topLevelOrigin != nil {
// ok (we always have the syntax set for instantiation)
} else if _, rng := fn.syntax.(*ast.RangeStmt); rng && fn.Synthetic == "range-over-func yield" {
// ok (range-func-yields are both synthetic and keep syntax)