Bump viper version, fix nobrowser (#1991)

This commit is contained in:
kermieisinthehouse
2021-11-11 14:21:04 -08:00
committed by GitHub
parent 808202ba8a
commit a7ed0a7004
270 changed files with 12423 additions and 5794 deletions

View File

@@ -96,6 +96,8 @@ func Of64(k Key, v uint64) Label { return Label{key: k, packed: v} }
// access should be done with the From method of the key.
func (t Label) Unpack64() uint64 { return t.packed }
type stringptr unsafe.Pointer
// OfString creates a new label from a key and a string.
// This method is for implementing new key types, label creation should
// normally be done with the Of method of the key.
@@ -104,7 +106,7 @@ func OfString(k Key, v string) Label {
return Label{
key: k,
packed: uint64(hdr.Len),
untyped: unsafe.Pointer(hdr.Data),
untyped: stringptr(hdr.Data),
}
}
@@ -115,9 +117,9 @@ func OfString(k Key, v string) Label {
func (t Label) UnpackString() string {
var v string
hdr := (*reflect.StringHeader)(unsafe.Pointer(&v))
hdr.Data = uintptr(t.untyped.(unsafe.Pointer))
hdr.Data = uintptr(t.untyped.(stringptr))
hdr.Len = int(t.packed)
return *(*string)(unsafe.Pointer(hdr))
return v
}
// Valid returns true if the Label is a valid one (it has a key).

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build freebsd || openbsd || netbsd
// +build freebsd openbsd netbsd
package fastwalk

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (linux || darwin) && !appengine
// +build linux darwin
// +build !appengine

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build darwin || freebsd || openbsd || netbsd
// +build darwin freebsd openbsd netbsd
package fastwalk

View File

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build linux
// +build !appengine
//go:build linux && !appengine
// +build linux,!appengine
package fastwalk

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build appengine || (!linux && !darwin && !freebsd && !openbsd && !netbsd)
// +build appengine !linux,!darwin,!freebsd,!openbsd,!netbsd
package fastwalk

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build (linux || darwin || freebsd || openbsd || netbsd) && !appengine
// +build linux darwin freebsd openbsd netbsd
// +build !appengine
@@ -21,7 +22,7 @@ const blockSize = 8 << 10
const unknownFileMode os.FileMode = os.ModeNamedPipe | os.ModeSocket | os.ModeDevice
func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) error) error {
fd, err := syscall.Open(dirName, 0, 0)
fd, err := open(dirName, 0, 0)
if err != nil {
return &os.PathError{Op: "open", Path: dirName, Err: err}
}
@@ -35,7 +36,7 @@ func readDir(dirName string, fn func(dirName, entName string, typ os.FileMode) e
for {
if bufp >= nbuf {
bufp = 0
nbuf, err = syscall.ReadDirent(fd, buf)
nbuf, err = readDirent(fd, buf)
if err != nil {
return os.NewSyscallError("readdirent", err)
}
@@ -126,3 +127,27 @@ func parseDirEnt(buf []byte) (consumed int, name string, typ os.FileMode) {
}
return
}
// According to https://golang.org/doc/go1.14#runtime
// A consequence of the implementation of preemption is that on Unix systems, including Linux and macOS
// systems, programs built with Go 1.14 will receive more signals than programs built with earlier releases.
//
// This causes syscall.Open and syscall.ReadDirent sometimes fail with EINTR errors.
// We need to retry in this case.
func open(path string, mode int, perm uint32) (fd int, err error) {
for {
fd, err := syscall.Open(path, mode, perm)
if err != syscall.EINTR {
return fd, err
}
}
}
func readDirent(fd int, buf []byte) (n int, err error) {
for {
nbuf, err := syscall.ReadDirent(fd, buf)
if err != syscall.EINTR {
return nbuf, err
}
}
}

View File

@@ -12,6 +12,7 @@ import (
"path/filepath"
"regexp"
"strings"
"time"
"golang.org/x/mod/semver"
)
@@ -19,11 +20,15 @@ import (
// ModuleJSON holds information about a module.
type ModuleJSON struct {
Path string // module path
Version string // module version
Versions []string // available module versions (with -versions)
Replace *ModuleJSON // replaced by this module
Time *time.Time // time version was created
Update *ModuleJSON // available update, if any (with -u)
Main bool // is this the main module?
Indirect bool // is this module only an indirect dependency of main module?
Dir string // directory holding files for this module, if any
GoMod string // path to go.mod file for this module, if any
GoMod string // path to go.mod file used when loading this module, if any
GoVersion string // go version used in module
}

View File

@@ -14,7 +14,7 @@ import (
// It returns the X in Go 1.X.
func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) {
inv.Verb = "list"
inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`}
inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`, `--`, `unsafe`}
inv.Env = append(append([]string{}, inv.Env...), "GO111MODULE=off")
// Unset any unneeded flags, and remove them from BuildFlags, if they're
// present.

View File

@@ -89,8 +89,10 @@ func (r *ModuleResolver) init() error {
err := r.initAllMods()
// We expect an error when running outside of a module with
// GO111MODULE=on. Other errors are fatal.
if err != nil && !strings.Contains(err.Error(), "working directory is not part of a module") {
return err
if err != nil {
if errMsg := err.Error(); !strings.Contains(errMsg, "working directory is not part of a module") && !strings.Contains(errMsg, "go.mod file not found") {
return err
}
}
}

View File

@@ -974,13 +974,29 @@ var stdlib = map[string][]string{
"DF_STATIC_TLS",
"DF_SYMBOLIC",
"DF_TEXTREL",
"DT_ADDRRNGHI",
"DT_ADDRRNGLO",
"DT_AUDIT",
"DT_AUXILIARY",
"DT_BIND_NOW",
"DT_CHECKSUM",
"DT_CONFIG",
"DT_DEBUG",
"DT_DEPAUDIT",
"DT_ENCODING",
"DT_FEATURE",
"DT_FILTER",
"DT_FINI",
"DT_FINI_ARRAY",
"DT_FINI_ARRAYSZ",
"DT_FLAGS",
"DT_FLAGS_1",
"DT_GNU_CONFLICT",
"DT_GNU_CONFLICTSZ",
"DT_GNU_HASH",
"DT_GNU_LIBLIST",
"DT_GNU_LIBLISTSZ",
"DT_GNU_PRELINKED",
"DT_HASH",
"DT_HIOS",
"DT_HIPROC",
@@ -990,28 +1006,100 @@ var stdlib = map[string][]string{
"DT_JMPREL",
"DT_LOOS",
"DT_LOPROC",
"DT_MIPS_AUX_DYNAMIC",
"DT_MIPS_BASE_ADDRESS",
"DT_MIPS_COMPACT_SIZE",
"DT_MIPS_CONFLICT",
"DT_MIPS_CONFLICTNO",
"DT_MIPS_CXX_FLAGS",
"DT_MIPS_DELTA_CLASS",
"DT_MIPS_DELTA_CLASSSYM",
"DT_MIPS_DELTA_CLASSSYM_NO",
"DT_MIPS_DELTA_CLASS_NO",
"DT_MIPS_DELTA_INSTANCE",
"DT_MIPS_DELTA_INSTANCE_NO",
"DT_MIPS_DELTA_RELOC",
"DT_MIPS_DELTA_RELOC_NO",
"DT_MIPS_DELTA_SYM",
"DT_MIPS_DELTA_SYM_NO",
"DT_MIPS_DYNSTR_ALIGN",
"DT_MIPS_FLAGS",
"DT_MIPS_GOTSYM",
"DT_MIPS_GP_VALUE",
"DT_MIPS_HIDDEN_GOTIDX",
"DT_MIPS_HIPAGENO",
"DT_MIPS_ICHECKSUM",
"DT_MIPS_INTERFACE",
"DT_MIPS_INTERFACE_SIZE",
"DT_MIPS_IVERSION",
"DT_MIPS_LIBLIST",
"DT_MIPS_LIBLISTNO",
"DT_MIPS_LOCALPAGE_GOTIDX",
"DT_MIPS_LOCAL_GOTIDX",
"DT_MIPS_LOCAL_GOTNO",
"DT_MIPS_MSYM",
"DT_MIPS_OPTIONS",
"DT_MIPS_PERF_SUFFIX",
"DT_MIPS_PIXIE_INIT",
"DT_MIPS_PLTGOT",
"DT_MIPS_PROTECTED_GOTIDX",
"DT_MIPS_RLD_MAP",
"DT_MIPS_RLD_MAP_REL",
"DT_MIPS_RLD_TEXT_RESOLVE_ADDR",
"DT_MIPS_RLD_VERSION",
"DT_MIPS_RWPLT",
"DT_MIPS_SYMBOL_LIB",
"DT_MIPS_SYMTABNO",
"DT_MIPS_TIME_STAMP",
"DT_MIPS_UNREFEXTNO",
"DT_MOVEENT",
"DT_MOVESZ",
"DT_MOVETAB",
"DT_NEEDED",
"DT_NULL",
"DT_PLTGOT",
"DT_PLTPAD",
"DT_PLTPADSZ",
"DT_PLTREL",
"DT_PLTRELSZ",
"DT_POSFLAG_1",
"DT_PPC64_GLINK",
"DT_PPC64_OPD",
"DT_PPC64_OPDSZ",
"DT_PPC64_OPT",
"DT_PPC_GOT",
"DT_PPC_OPT",
"DT_PREINIT_ARRAY",
"DT_PREINIT_ARRAYSZ",
"DT_REL",
"DT_RELA",
"DT_RELACOUNT",
"DT_RELAENT",
"DT_RELASZ",
"DT_RELCOUNT",
"DT_RELENT",
"DT_RELSZ",
"DT_RPATH",
"DT_RUNPATH",
"DT_SONAME",
"DT_SPARC_REGISTER",
"DT_STRSZ",
"DT_STRTAB",
"DT_SYMBOLIC",
"DT_SYMENT",
"DT_SYMINENT",
"DT_SYMINFO",
"DT_SYMINSZ",
"DT_SYMTAB",
"DT_SYMTAB_SHNDX",
"DT_TEXTREL",
"DT_TLSDESC_GOT",
"DT_TLSDESC_PLT",
"DT_USED",
"DT_VALRNGHI",
"DT_VALRNGLO",
"DT_VERDEF",
"DT_VERDEFNUM",
"DT_VERNEED",
"DT_VERNEEDNUM",
"DT_VERSYM",
@@ -1271,17 +1359,38 @@ var stdlib = map[string][]string{
"PF_R",
"PF_W",
"PF_X",
"PT_AARCH64_ARCHEXT",
"PT_AARCH64_UNWIND",
"PT_ARM_ARCHEXT",
"PT_ARM_EXIDX",
"PT_DYNAMIC",
"PT_GNU_EH_FRAME",
"PT_GNU_MBIND_HI",
"PT_GNU_MBIND_LO",
"PT_GNU_PROPERTY",
"PT_GNU_RELRO",
"PT_GNU_STACK",
"PT_HIOS",
"PT_HIPROC",
"PT_INTERP",
"PT_LOAD",
"PT_LOOS",
"PT_LOPROC",
"PT_MIPS_ABIFLAGS",
"PT_MIPS_OPTIONS",
"PT_MIPS_REGINFO",
"PT_MIPS_RTPROC",
"PT_NOTE",
"PT_NULL",
"PT_OPENBSD_BOOTDATA",
"PT_OPENBSD_RANDOMIZE",
"PT_OPENBSD_WXNEEDED",
"PT_PAX_FLAGS",
"PT_PHDR",
"PT_S390_PGSTE",
"PT_SHLIB",
"PT_SUNWSTACK",
"PT_SUNW_EH_FRAME",
"PT_TLS",
"Prog",
"Prog32",
@@ -2445,6 +2554,9 @@ var stdlib = map[string][]string{
"SectionHeader",
"Sym",
},
"embed": []string{
"FS",
},
"encoding": []string{
"BinaryMarshaler",
"BinaryUnmarshaler",
@@ -2680,6 +2792,7 @@ var stdlib = map[string][]string{
"FlagSet",
"Float64",
"Float64Var",
"Func",
"Getter",
"Int",
"Int64",
@@ -2853,6 +2966,18 @@ var stdlib = map[string][]string{
"Package",
"ToolDir",
},
"go/build/constraint": []string{
"AndExpr",
"Expr",
"IsGoBuild",
"IsPlusBuild",
"NotExpr",
"OrExpr",
"Parse",
"PlusBuildLines",
"SyntaxError",
"TagExpr",
},
"go/constant": []string{
"BinaryOp",
"BitLen",
@@ -3273,6 +3398,7 @@ var stdlib = map[string][]string{
"Must",
"New",
"OK",
"ParseFS",
"ParseFiles",
"ParseGlob",
"Srcset",
@@ -3432,6 +3558,7 @@ var stdlib = map[string][]string{
"Copy",
"CopyBuffer",
"CopyN",
"Discard",
"EOF",
"ErrClosedPipe",
"ErrNoProgress",
@@ -3443,12 +3570,15 @@ var stdlib = map[string][]string{
"MultiReader",
"MultiWriter",
"NewSectionReader",
"NopCloser",
"Pipe",
"PipeReader",
"PipeWriter",
"ReadAll",
"ReadAtLeast",
"ReadCloser",
"ReadFull",
"ReadSeekCloser",
"ReadSeeker",
"ReadWriteCloser",
"ReadWriteSeeker",
@@ -3472,6 +3602,49 @@ var stdlib = map[string][]string{
"WriterAt",
"WriterTo",
},
"io/fs": []string{
"DirEntry",
"ErrClosed",
"ErrExist",
"ErrInvalid",
"ErrNotExist",
"ErrPermission",
"FS",
"File",
"FileInfo",
"FileMode",
"Glob",
"GlobFS",
"ModeAppend",
"ModeCharDevice",
"ModeDevice",
"ModeDir",
"ModeExclusive",
"ModeIrregular",
"ModeNamedPipe",
"ModePerm",
"ModeSetgid",
"ModeSetuid",
"ModeSocket",
"ModeSticky",
"ModeSymlink",
"ModeTemporary",
"ModeType",
"PathError",
"ReadDir",
"ReadDirFS",
"ReadDirFile",
"ReadFile",
"ReadFileFS",
"SkipDir",
"Stat",
"StatFS",
"Sub",
"SubFS",
"ValidPath",
"WalkDir",
"WalkDirFunc",
},
"io/ioutil": []string{
"Discard",
"NopCloser",
@@ -3483,6 +3656,7 @@ var stdlib = map[string][]string{
"WriteFile",
},
"log": []string{
"Default",
"Fatal",
"Fatalf",
"Fatalln",
@@ -3819,6 +3993,7 @@ var stdlib = map[string][]string{
"DialUDP",
"DialUnix",
"Dialer",
"ErrClosed",
"ErrWriteToConnected",
"Error",
"FileConn",
@@ -3938,6 +4113,7 @@ var stdlib = map[string][]string{
"ErrUseLastResponse",
"ErrWriteAfterFlush",
"Error",
"FS",
"File",
"FileServer",
"FileSystem",
@@ -4234,7 +4410,10 @@ var stdlib = map[string][]string{
"Chtimes",
"Clearenv",
"Create",
"CreateTemp",
"DevNull",
"DirEntry",
"DirFS",
"Environ",
"ErrClosed",
"ErrDeadlineExceeded",
@@ -4243,6 +4422,7 @@ var stdlib = map[string][]string{
"ErrNoDeadline",
"ErrNotExist",
"ErrPermission",
"ErrProcessDone",
"Executable",
"Exit",
"Expand",
@@ -4276,6 +4456,7 @@ var stdlib = map[string][]string{
"Lstat",
"Mkdir",
"MkdirAll",
"MkdirTemp",
"ModeAppend",
"ModeCharDevice",
"ModeDevice",
@@ -4310,6 +4491,8 @@ var stdlib = map[string][]string{
"ProcAttr",
"Process",
"ProcessState",
"ReadDir",
"ReadFile",
"Readlink",
"Remove",
"RemoveAll",
@@ -4333,6 +4516,7 @@ var stdlib = map[string][]string{
"UserCacheDir",
"UserConfigDir",
"UserHomeDir",
"WriteFile",
},
"os/exec": []string{
"Cmd",
@@ -4347,6 +4531,7 @@ var stdlib = map[string][]string{
"Ignore",
"Ignored",
"Notify",
"NotifyContext",
"Reset",
"Stop",
},
@@ -4397,6 +4582,7 @@ var stdlib = map[string][]string{
"ToSlash",
"VolumeName",
"Walk",
"WalkDir",
"WalkFunc",
},
"plugin": []string{
@@ -4629,6 +4815,19 @@ var stdlib = map[string][]string{
"Stack",
"WriteHeapDump",
},
"runtime/metrics": []string{
"All",
"Description",
"Float64Histogram",
"KindBad",
"KindFloat64",
"KindFloat64Histogram",
"KindUint64",
"Read",
"Sample",
"Value",
"ValueKind",
},
"runtime/pprof": []string{
"Do",
"ForLabels",
@@ -5012,6 +5211,8 @@ var stdlib = map[string][]string{
"AddrinfoW",
"Adjtime",
"Adjtimex",
"AllThreadsSyscall",
"AllThreadsSyscall6",
"AttachLsf",
"B0",
"B1000000",
@@ -10010,13 +10211,20 @@ var stdlib = map[string][]string{
"TB",
"Verbose",
},
"testing/fstest": []string{
"MapFS",
"MapFile",
"TestFS",
},
"testing/iotest": []string{
"DataErrReader",
"ErrReader",
"ErrTimeout",
"HalfReader",
"NewReadLogger",
"NewWriteLogger",
"OneByteReader",
"TestReader",
"TimeoutReader",
"TruncateWriter",
},
@@ -10076,6 +10284,7 @@ var stdlib = map[string][]string{
"JSEscaper",
"Must",
"New",
"ParseFS",
"ParseFiles",
"ParseGlob",
"Template",
@@ -10087,12 +10296,14 @@ var stdlib = map[string][]string{
"BranchNode",
"ChainNode",
"CommandNode",
"CommentNode",
"DotNode",
"FieldNode",
"IdentifierNode",
"IfNode",
"IsEmptyTree",
"ListNode",
"Mode",
"New",
"NewIdentifier",
"NilNode",
@@ -10101,6 +10312,7 @@ var stdlib = map[string][]string{
"NodeBool",
"NodeChain",
"NodeCommand",
"NodeComment",
"NodeDot",
"NodeField",
"NodeIdentifier",
@@ -10118,6 +10330,7 @@ var stdlib = map[string][]string{
"NodeWith",
"NumberNode",
"Parse",
"ParseComments",
"PipeNode",
"Pos",
"RangeNode",
@@ -10230,6 +10443,7 @@ var stdlib = map[string][]string{
"Chakma",
"Cham",
"Cherokee",
"Chorasmian",
"Co",
"Common",
"Coptic",
@@ -10243,6 +10457,7 @@ var stdlib = map[string][]string{
"Devanagari",
"Diacritic",
"Digit",
"Dives_Akuru",
"Dogra",
"Duployan",
"Egyptian_Hieroglyphs",
@@ -10300,6 +10515,7 @@ var stdlib = map[string][]string{
"Katakana",
"Kayah_Li",
"Kharoshthi",
"Khitan_Small_Script",
"Khmer",
"Khojki",
"Khudawadi",
@@ -10472,6 +10688,7 @@ var stdlib = map[string][]string{
"Wancho",
"Warang_Citi",
"White_Space",
"Yezidi",
"Yi",
"Z",
"Zanabazar_Square",

View File

@@ -10,6 +10,13 @@ import (
)
var GetForTest = func(p interface{}) string { return "" }
var GetDepsErrors = func(p interface{}) []*PackageError { return nil }
type PackageError struct {
ImportStack []string // shortest path from package named on command line to this one
Pos string // position of error (if present, file:line:col)
Err string // the error itself
}
var GetGoCmdRunner = func(config interface{}) *gocommand.Runner { return nil }

11
vendor/golang.org/x/tools/internal/typeparams/doc.go generated vendored Normal file
View File

@@ -0,0 +1,11 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package typeparams provides functions to work indirectly with type parameter
// data stored in go/ast and go/types objects, while these API are guarded by a
// build constraint.
//
// This package exists to make it easier for tools to work with generic code,
// while also compiling against older Go versions.
package typeparams

View File

@@ -0,0 +1,90 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build !typeparams || !go1.17
// +build !typeparams !go1.17
package typeparams
import (
"go/ast"
"go/types"
)
// NOTE: doc comments must be kept in sync with typeparams.go.
// Enabled reports whether type parameters are enabled in the current build
// environment.
const Enabled = false
// UnpackIndex extracts all index expressions from e. For non-generic code this
// is always one expression: e.Index, but may be more than one expression for
// generic type instantiation.
func UnpackIndex(e *ast.IndexExpr) []ast.Expr {
return []ast.Expr{e.Index}
}
// IsListExpr reports whether n is an *ast.ListExpr, which is a new node type
// introduced to hold type arguments for generic type instantiation.
func IsListExpr(n ast.Node) bool {
return false
}
// ForTypeDecl extracts the (possibly nil) type parameter node list from n.
func ForTypeDecl(*ast.TypeSpec) *ast.FieldList {
return nil
}
// ForFuncDecl extracts the (possibly nil) type parameter node list from n.
func ForFuncDecl(*ast.FuncDecl) *ast.FieldList {
return nil
}
// ForSignature extracts the (possibly empty) type parameter object list from
// sig.
func ForSignature(*types.Signature) []*types.TypeName {
return nil
}
// HasTypeSet reports if iface has a type set.
func HasTypeSet(*types.Interface) bool {
return false
}
// IsComparable reports if iface is the comparable interface.
func IsComparable(*types.Interface) bool {
return false
}
// IsConstraint reports whether iface may only be used as a type parameter
// constraint (i.e. has a type set or is the comparable interface).
func IsConstraint(*types.Interface) bool {
return false
}
// ForNamed extracts the (possibly empty) type parameter object list from
// named.
func ForNamed(*types.Named) []*types.TypeName {
return nil
}
// NamedTArgs extracts the (possibly empty) type argument list from named.
func NamedTArgs(*types.Named) []types.Type {
return nil
}
// InitInferred initializes info to record inferred type information.
func InitInferred(*types.Info) {
}
// GetInferred extracts inferred type information from info for e.
//
// The expression e may have an inferred type if it is an *ast.IndexExpr
// representing partial instantiation of a generic function type for which type
// arguments have been inferred using constraint type inference, or if it is an
// *ast.CallExpr for which type type arguments have be inferred using both
// constraint type inference and function argument inference.
func GetInferred(*types.Info, ast.Expr) ([]types.Type, *types.Signature) {
return nil, nil
}

View File

@@ -0,0 +1,105 @@
// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build typeparams && go1.17
// +build typeparams,go1.17
package typeparams
import (
"go/ast"
"go/types"
)
// NOTE: doc comments must be kept in sync with notypeparams.go.
// Enabled reports whether type parameters are enabled in the current build
// environment.
const Enabled = true
// UnpackIndex extracts all index expressions from e. For non-generic code this
// is always one expression: e.Index, but may be more than one expression for
// generic type instantiation.
func UnpackIndex(e *ast.IndexExpr) []ast.Expr {
if x, _ := e.Index.(*ast.ListExpr); x != nil {
return x.ElemList
}
if e.Index != nil {
return []ast.Expr{e.Index}
}
return nil
}
// IsListExpr reports whether n is an *ast.ListExpr, which is a new node type
// introduced to hold type arguments for generic type instantiation.
func IsListExpr(n ast.Node) bool {
_, ok := n.(*ast.ListExpr)
return ok
}
// ForTypeDecl extracts the (possibly nil) type parameter node list from n.
func ForTypeDecl(n *ast.TypeSpec) *ast.FieldList {
return n.TParams
}
// ForFuncDecl extracts the (possibly nil) type parameter node list from n.
func ForFuncDecl(n *ast.FuncDecl) *ast.FieldList {
if n.Type != nil {
return n.Type.TParams
}
return nil
}
// ForSignature extracts the (possibly empty) type parameter object list from
// sig.
func ForSignature(sig *types.Signature) []*types.TypeName {
return sig.TParams()
}
// HasTypeSet reports if iface has a type set.
func HasTypeSet(iface *types.Interface) bool {
return iface.HasTypeList()
}
// IsComparable reports if iface is the comparable interface.
func IsComparable(iface *types.Interface) bool {
return iface.IsComparable()
}
// IsConstraint reports whether iface may only be used as a type parameter
// constraint (i.e. has a type set or is the comparable interface).
func IsConstraint(iface *types.Interface) bool {
return iface.IsConstraint()
}
// ForNamed extracts the (possibly empty) type parameter object list from
// named.
func ForNamed(named *types.Named) []*types.TypeName {
return named.TParams()
}
// NamedTArgs extracts the (possibly empty) type argument list from named.
func NamedTArgs(named *types.Named) []types.Type {
return named.TArgs()
}
// InitInferred initializes info to record inferred type information.
func InitInferred(info *types.Info) {
info.Inferred = make(map[ast.Expr]types.Inferred)
}
// GetInferred extracts inferred type information from info for e.
//
// The expression e may have an inferred type if it is an *ast.IndexExpr
// representing partial instantiation of a generic function type for which type
// arguments have been inferred using constraint type inference, or if it is an
// *ast.CallExpr for which type type arguments have be inferred using both
// constraint type inference and function argument inference.
func GetInferred(info *types.Info, e ast.Expr) ([]types.Type, *types.Signature) {
if info.Inferred == nil {
return nil, nil
}
inf := info.Inferred[e]
return inf.TArgs, inf.Sig
}

View File

@@ -1209,6 +1209,16 @@ const (
// }
InvalidTypeSwitch
// InvalidExprSwitch occurs when a switch expression is not comparable.
//
// Example:
// func _() {
// var a struct{ _ func() }
// switch a /* ERROR cannot switch on a */ {
// }
// }
InvalidExprSwitch
/* control flow > select */
// InvalidSelectCase occurs when a select case is not a channel send or

View File

@@ -124,24 +124,25 @@ func _() {
_ = x[DuplicateDefault-114]
_ = x[BadTypeKeyword-115]
_ = x[InvalidTypeSwitch-116]
_ = x[InvalidSelectCase-117]
_ = x[UndeclaredLabel-118]
_ = x[DuplicateLabel-119]
_ = x[MisplacedLabel-120]
_ = x[UnusedLabel-121]
_ = x[JumpOverDecl-122]
_ = x[JumpIntoBlock-123]
_ = x[InvalidMethodExpr-124]
_ = x[WrongArgCount-125]
_ = x[InvalidCall-126]
_ = x[UnusedResults-127]
_ = x[InvalidDefer-128]
_ = x[InvalidGo-129]
_ = x[InvalidExprSwitch-117]
_ = x[InvalidSelectCase-118]
_ = x[UndeclaredLabel-119]
_ = x[DuplicateLabel-120]
_ = x[MisplacedLabel-121]
_ = x[UnusedLabel-122]
_ = x[JumpOverDecl-123]
_ = x[JumpIntoBlock-124]
_ = x[InvalidMethodExpr-125]
_ = x[WrongArgCount-126]
_ = x[InvalidCall-127]
_ = x[UnusedResults-128]
_ = x[InvalidDefer-129]
_ = x[InvalidGo-130]
}
const _ErrorCode_name = "TestBlankPkgNameMismatchedPkgNameInvalidPkgUseBadImportPathBrokenImportImportCRenamedUnusedImportInvalidInitCycleDuplicateDeclInvalidDeclCycleInvalidTypeCycleInvalidConstInitInvalidConstValInvalidConstTypeUntypedNilWrongAssignCountUnassignableOperandNoNewVarMultiValAssignOpInvalidIfaceAssignInvalidChanAssignIncompatibleAssignUnaddressableFieldAssignNotATypeInvalidArrayLenBlankIfaceMethodIncomparableMapKeyInvalidIfaceEmbedInvalidPtrEmbedBadRecvInvalidRecvDuplicateFieldAndMethodDuplicateMethodInvalidBlankInvalidIotaMissingInitBodyInvalidInitSigInvalidInitDeclInvalidMainDeclTooManyValuesNotAnExprTruncatedFloatNumericOverflowUndefinedOpMismatchedTypesDivByZeroNonNumericIncDecUnaddressableOperandInvalidIndirectionNonIndexableOperandInvalidIndexSwappedSliceIndicesNonSliceableOperandInvalidSliceExprInvalidShiftCountInvalidShiftOperandInvalidReceiveInvalidSendDuplicateLitKeyMissingLitKeyInvalidLitIndexOversizeArrayLitMixedStructLitInvalidStructLitMissingLitFieldDuplicateLitFieldUnexportedLitFieldInvalidLitFieldUntypedLitInvalidLitAmbiguousSelectorUndeclaredImportedNameUnexportedNameUndeclaredNameMissingFieldOrMethodBadDotDotDotSyntaxNonVariadicDotDotDotMisplacedDotDotDotInvalidDotDotDotOperandInvalidDotDotDotUncalledBuiltinInvalidAppendInvalidCapInvalidCloseInvalidCopyInvalidComplexInvalidDeleteInvalidImagInvalidLenSwappedMakeArgsInvalidMakeInvalidRealInvalidAssertImpossibleAssertInvalidConversionInvalidUntypedConversionBadOffsetofSyntaxInvalidOffsetofUnusedExprUnusedVarMissingReturnWrongResultCountOutOfScopeResultInvalidCondInvalidPostDeclInvalidChanRangeInvalidIterVarInvalidRangeExprMisplacedBreakMisplacedContinueMisplacedFallthroughDuplicateCaseDuplicateDefaultBadTypeKeywordInvalidTypeSwitchInvalidSelectCaseUndeclaredLabelDuplicateLabelMisplacedLabelUnusedLabelJumpOverDeclJumpIntoBlockInvalidMethodExprWrongArgCountInvalidCallUnusedResultsInvalidDeferInvalidGo"
const _ErrorCode_name = "TestBlankPkgNameMismatchedPkgNameInvalidPkgUseBadImportPathBrokenImportImportCRenamedUnusedImportInvalidInitCycleDuplicateDeclInvalidDeclCycleInvalidTypeCycleInvalidConstInitInvalidConstValInvalidConstTypeUntypedNilWrongAssignCountUnassignableOperandNoNewVarMultiValAssignOpInvalidIfaceAssignInvalidChanAssignIncompatibleAssignUnaddressableFieldAssignNotATypeInvalidArrayLenBlankIfaceMethodIncomparableMapKeyInvalidIfaceEmbedInvalidPtrEmbedBadRecvInvalidRecvDuplicateFieldAndMethodDuplicateMethodInvalidBlankInvalidIotaMissingInitBodyInvalidInitSigInvalidInitDeclInvalidMainDeclTooManyValuesNotAnExprTruncatedFloatNumericOverflowUndefinedOpMismatchedTypesDivByZeroNonNumericIncDecUnaddressableOperandInvalidIndirectionNonIndexableOperandInvalidIndexSwappedSliceIndicesNonSliceableOperandInvalidSliceExprInvalidShiftCountInvalidShiftOperandInvalidReceiveInvalidSendDuplicateLitKeyMissingLitKeyInvalidLitIndexOversizeArrayLitMixedStructLitInvalidStructLitMissingLitFieldDuplicateLitFieldUnexportedLitFieldInvalidLitFieldUntypedLitInvalidLitAmbiguousSelectorUndeclaredImportedNameUnexportedNameUndeclaredNameMissingFieldOrMethodBadDotDotDotSyntaxNonVariadicDotDotDotMisplacedDotDotDotInvalidDotDotDotOperandInvalidDotDotDotUncalledBuiltinInvalidAppendInvalidCapInvalidCloseInvalidCopyInvalidComplexInvalidDeleteInvalidImagInvalidLenSwappedMakeArgsInvalidMakeInvalidRealInvalidAssertImpossibleAssertInvalidConversionInvalidUntypedConversionBadOffsetofSyntaxInvalidOffsetofUnusedExprUnusedVarMissingReturnWrongResultCountOutOfScopeResultInvalidCondInvalidPostDeclInvalidChanRangeInvalidIterVarInvalidRangeExprMisplacedBreakMisplacedContinueMisplacedFallthroughDuplicateCaseDuplicateDefaultBadTypeKeywordInvalidTypeSwitchInvalidExprSwitchInvalidSelectCaseUndeclaredLabelDuplicateLabelMisplacedLabelUnusedLabelJumpOverDeclJumpIntoBlockInvalidMethodExprWrongArgCountInvalidCallUnusedResultsInvalidDeferInvalidGo"
var _ErrorCode_index = [...]uint16{0, 4, 16, 33, 46, 59, 71, 85, 97, 113, 126, 142, 158, 174, 189, 205, 215, 231, 250, 258, 274, 292, 309, 327, 351, 359, 374, 390, 408, 425, 440, 447, 458, 481, 496, 508, 519, 534, 548, 563, 578, 591, 600, 614, 629, 640, 655, 664, 680, 700, 718, 737, 749, 768, 787, 803, 820, 839, 853, 864, 879, 892, 907, 923, 937, 953, 968, 985, 1003, 1018, 1028, 1038, 1055, 1077, 1091, 1105, 1125, 1143, 1163, 1181, 1204, 1220, 1235, 1248, 1258, 1270, 1281, 1295, 1308, 1319, 1329, 1344, 1355, 1366, 1379, 1395, 1412, 1436, 1453, 1468, 1478, 1487, 1500, 1516, 1532, 1543, 1558, 1574, 1588, 1604, 1618, 1635, 1655, 1668, 1684, 1698, 1715, 1732, 1747, 1761, 1775, 1786, 1798, 1811, 1828, 1841, 1852, 1865, 1877, 1886}
var _ErrorCode_index = [...]uint16{0, 4, 16, 33, 46, 59, 71, 85, 97, 113, 126, 142, 158, 174, 189, 205, 215, 231, 250, 258, 274, 292, 309, 327, 351, 359, 374, 390, 408, 425, 440, 447, 458, 481, 496, 508, 519, 534, 548, 563, 578, 591, 600, 614, 629, 640, 655, 664, 680, 700, 718, 737, 749, 768, 787, 803, 820, 839, 853, 864, 879, 892, 907, 923, 937, 953, 968, 985, 1003, 1018, 1028, 1038, 1055, 1077, 1091, 1105, 1125, 1143, 1163, 1181, 1204, 1220, 1235, 1248, 1258, 1270, 1281, 1295, 1308, 1319, 1329, 1344, 1355, 1366, 1379, 1395, 1412, 1436, 1453, 1468, 1478, 1487, 1500, 1516, 1532, 1543, 1558, 1574, 1588, 1604, 1618, 1635, 1655, 1668, 1684, 1698, 1715, 1732, 1749, 1764, 1778, 1792, 1803, 1815, 1828, 1845, 1858, 1869, 1882, 1894, 1903}
func (i ErrorCode) String() string {
i -= 1