type go/ast.Expr
307 uses
go/ast (current package)
ast.go#L42: type Expr interface {
ast.go#L204: Type Expr // field/method/parameter type; or nil
ast.go#L302: Elt Expr // ellipsis element type (parameter lists only); or nil
ast.go#L332: Type Expr // literal type; or nil
ast.go#L334: Elts []Expr // list of composite elements; or nil
ast.go#L342: X Expr // parenthesized expression
ast.go#L348: X Expr // expression
ast.go#L354: X Expr // expression
ast.go#L356: Index Expr // index expression
ast.go#L363: X Expr // expression
ast.go#L365: Indices []Expr // index expressions
ast.go#L371: X Expr // expression
ast.go#L373: Low Expr // begin of slice range; or nil
ast.go#L374: High Expr // end of slice range; or nil
ast.go#L375: Max Expr // maximum capacity of slice; or nil
ast.go#L384: X Expr // expression
ast.go#L386: Type Expr // asserted type; nil means type switch X.(type)
ast.go#L392: Fun Expr // function expression
ast.go#L394: Args []Expr // function arguments; or nil
ast.go#L404: X Expr // operand
ast.go#L413: X Expr // operand
ast.go#L418: X Expr // left operand
ast.go#L421: Y Expr // right operand
ast.go#L428: Key Expr
ast.go#L430: Value Expr
ast.go#L450: Len Expr // Ellipsis node for [...]T array types, nil for slice types
ast.go#L451: Elt Expr // element type
ast.go#L481: Key Expr
ast.go#L482: Value Expr
ast.go#L490: Value Expr // value type
ast.go#L650: X Expr // expression
ast.go#L655: Chan Expr
ast.go#L657: Value Expr
ast.go#L662: X Expr
ast.go#L671: Lhs []Expr
ast.go#L674: Rhs []Expr
ast.go#L692: Results []Expr // result expressions; or nil
ast.go#L715: Cond Expr // condition
ast.go#L723: List []Expr // list of expressions or types; nil means default case
ast.go#L732: Tag Expr // tag expression; or nil
ast.go#L762: Cond Expr // condition; or nil
ast.go#L770: Key, Value Expr // Key, Value may be nil
ast.go#L774: X Expr // value to range over
ast.go#L916: Type Expr // value type; or nil
ast.go#L917: Values []Expr // initial values; or nil
ast.go#L927: Type Expr // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes
ast.go#L1140: func Unparen(e Expr) Expr {
filter.go#L63: func fieldName(x Expr) *Ident {
filter.go#L120: func filterExprList(list []Expr, filter Filter, export bool) []Expr {
filter.go#L153: func filterType(typ Expr, f Filter, export bool) bool {
go/doc
exports.go#L37: func filterExprList(list []ast.Expr, filter Filter, export bool) []ast.Expr {
exports.go#L170: func (r *reader) filterType(parent *namedType, typ ast.Expr) {
exports.go#L253: func copyConstType(typ ast.Expr, pos token.Pos) ast.Expr {
exports.go#L273: var prevType ast.Expr
reader.go#L32: func recvString(recv ast.Expr) string {
reader.go#L59: func recvParam(p ast.Expr) string {
reader.go#L83: var typ ast.Expr
reader.go#L125: func baseTypeName(x ast.Expr) (name string, imported bool) {
reader.go#L231: func (r *reader) recordAnonymousField(parent *namedType, fieldType ast.Expr) (fname string) {
reader.go#L347: func fields(typ ast.Expr) (list []*ast.Field, isStruct bool) {
reader.go#L707: var typ ast.Expr = newIdent
go/parser
interface.go#L203: func ParseExprFrom(fset *token.FileSet, filename string, src any, mode Mode) (expr ast.Expr, err error) {
interface.go#L251: func ParseExpr(x string) (ast.Expr, error) {
parser.go#L510: func (p *parser) parseExprList() (list []ast.Expr) {
parser.go#L524: func (p *parser) parseList(inRhs bool) []ast.Expr {
parser.go#L535: func (p *parser) parseType() ast.Expr {
parser.go#L552: func (p *parser) parseQualifiedIdent(ident *ast.Ident) ast.Expr {
parser.go#L566: func (p *parser) parseTypeName(ident *ast.Ident) ast.Expr {
parser.go#L587: func (p *parser) parseArrayType(lbrack token.Pos, len ast.Expr) *ast.ArrayType {
parser.go#L615: func (p *parser) parseArrayFieldOrTypeInstance(x *ast.Ident) (*ast.Ident, ast.Expr) {
parser.go#L622: var args []ast.Expr
parser.go#L670: var typ ast.Expr
parser.go#L803: typ ast.Expr
parser.go#L889: func (p *parser) parseParameterList(name0 *ast.Ident, typ0 ast.Expr, closing token.Token, dddok bool) (params []*ast.Field) {
parser.go#L975: var typ ast.Expr // current type (from right to left)
parser.go#L1057: var typ ast.Expr
parser.go#L1149: var typ ast.Expr
parser.go#L1181: list := []ast.Expr{x}
parser.go#L1224: func (p *parser) embeddedElem(x ast.Expr) ast.Expr {
parser.go#L1243: func (p *parser) embeddedTerm() ast.Expr {
parser.go#L1355: func (p *parser) parseTypeInstance(typ ast.Expr) ast.Expr {
parser.go#L1362: var list []ast.Expr
parser.go#L1387: func (p *parser) tryIdentOrType() ast.Expr {
parser.go#L1466: func (p *parser) parseFuncTypeOrLit() ast.Expr {
parser.go#L1486: func (p *parser) parseOperand() ast.Expr {
parser.go#L1528: func (p *parser) parseSelector(x ast.Expr) ast.Expr {
parser.go#L1538: func (p *parser) parseTypeAssertion(x ast.Expr) ast.Expr {
parser.go#L1544: var typ ast.Expr
parser.go#L1556: func (p *parser) parseIndexOrSliceOrInstance(x ast.Expr) ast.Expr {
parser.go#L1578: var args []ast.Expr
parser.go#L1579: var index [N]ast.Expr
parser.go#L1640: func (p *parser) parseCallOrConversion(fun ast.Expr) *ast.CallExpr {
parser.go#L1647: var list []ast.Expr
parser.go#L1666: func (p *parser) parseValue() ast.Expr {
parser.go#L1680: func (p *parser) parseElement() ast.Expr {
parser.go#L1695: func (p *parser) parseElementList() (list []ast.Expr) {
parser.go#L1711: func (p *parser) parseLiteralValue(typ ast.Expr) ast.Expr {
parser.go#L1719: var elts []ast.Expr
parser.go#L1729: func (p *parser) parsePrimaryExpr(x ast.Expr) ast.Expr {
parser.go#L1802: func (p *parser) parseUnaryExpr() ast.Expr {
parser.go#L1885: func (p *parser) parseBinaryExpr(x ast.Expr, prec1 int) ast.Expr {
parser.go#L1911: func (p *parser) parseExpr() ast.Expr {
parser.go#L1919: func (p *parser) parseRhs() ast.Expr {
parser.go#L1957: var y []ast.Expr
parser.go#L1962: y = []ast.Expr{&ast.UnaryExpr{OpPos: pos, Op: token.RANGE, X: p.parseRhs()}}
parser.go#L2067: var x []ast.Expr
parser.go#L2091: func (p *parser) makeExpr(s ast.Stmt, want string) ast.Expr {
parser.go#L2109: func (p *parser) parseIfHeader() (init ast.Stmt, cond ast.Expr) {
parser.go#L2207: var list []ast.Expr
parser.go#L2221: func isTypeSwitchAssert(x ast.Expr) bool {
parser.go#L2333: comm = &ast.AssignStmt{Lhs: lhs, TokPos: pos, Tok: tok, Rhs: []ast.Expr{rhs}}
parser.go#L2388: y := []ast.Expr{&ast.UnaryExpr{OpPos: pos, Op: token.RANGE, X: p.parseRhs()}}
parser.go#L2416: var key, value ast.Expr
parser.go#L2565: var typ ast.Expr
parser.go#L2566: var values []ast.Expr
parser.go#L2600: func (p *parser) parseGenericType(spec *ast.TypeSpec, openPos token.Pos, name0 *ast.Ident, typ0 ast.Expr) {
parser.go#L2645: var x ast.Expr = p.parseIdent()
parser.go#L2709: func extractName(x ast.Expr, force bool) (*ast.Ident, ast.Expr) {
parser.go#L2747: func isTypeElem(x ast.Expr) bool {
parser.go#L2956: func packIndexExpr(x ast.Expr, lbrack token.Pos, exprs []ast.Expr, rbrack token.Pos) ast.Expr {
resolver.go#L229: func (r *resolver) walkExprs(list []ast.Expr) {
resolver.go#L235: func (r *resolver) walkLHS(list []ast.Expr) {
resolver.go#L419: var lhs []ast.Expr
resolver.go#L436: Rhs: []ast.Expr{&ast.UnaryExpr{Op: token.RANGE, X: n.X}},
resolver.go#L555: var declareExprs []ast.Expr // exprs to declare
resolver.go#L556: var resolveExprs []ast.Expr // exprs to resolve
resolver.go#L559: declareExprs = []ast.Expr{typ.Index}
go/printer
nodes.go#L105: xlist := make([]ast.Expr, len(list))
nodes.go#L126: func (p *printer) exprList(prev0 token.Pos, list []ast.Expr, depth int, mode exprListMode, next0 token.Pos, isIncomplete bool) {
nodes.go#L406: func combinesWithName(x ast.Expr) bool {
nodes.go#L421: func isTypeElem(x ast.Expr) bool {
nodes.go#L716: func diffPrec(expr ast.Expr, prec int) int {
nodes.go#L808: func isBinary(expr ast.Expr) bool {
nodes.go#L813: func (p *printer) expr1(expr ast.Expr, prec1, depth int) {
nodes.go#L933: indices := []ast.Expr{x.Low, x.High}
nodes.go#L1147: func (p *printer) possibleSelectorExpr(expr ast.Expr, prec1, depth int) bool {
nodes.go#L1174: func (p *printer) expr0(x ast.Expr, depth int) {
nodes.go#L1178: func (p *printer) expr(x ast.Expr) {
nodes.go#L1236: func isTypeName(x ast.Expr) bool {
nodes.go#L1246: func stripParens(x ast.Expr) ast.Expr {
nodes.go#L1272: func stripParensAlways(x ast.Expr) ast.Expr {
nodes.go#L1279: func (p *printer) controlClause(isForStmt bool, init ast.Stmt, expr ast.Expr, post ast.Stmt) {
nodes.go#L1316: func (p *printer) indentList(list []ast.Expr) bool {
printer.go#L1147: case ast.Expr:
go/types
api.go#L238: Types map[ast.Expr]TypeAndValue
api.go#L346: func (info *Info) TypeOf(e ast.Expr) Type {
api.go#L463: Rhs ast.Expr
assignments.go#L188: func (check *Checker) lhsVar(lhs ast.Expr) Type {
assignments.go#L252: func (check *Checker) assignVar(lhs, rhs ast.Expr, x *operand, context string) {
assignments.go#L354: func (check *Checker) assignError(rhs []ast.Expr, l, r int) {
assignments.go#L388: func (check *Checker) initVars(lhs []*Var, orig_rhs []ast.Expr, returnStmt ast.Stmt) {
assignments.go#L472: func (check *Checker) assignVars(lhs, orig_rhs []ast.Expr) {
assignments.go#L526: func (check *Checker) shortVarDecl(pos positioner, lhs, rhs []ast.Expr) {
call.go#L48: var xlist []ast.Expr
call.go#L132: func (check *Checker) instantiateSignature(pos token.Pos, expr ast.Expr, typ *Signature, targs []Type, xlist []ast.Expr) (res *Signature) {
call.go#L267: var xlist []ast.Expr
call.go#L343: func (check *Checker) exprList(elist []ast.Expr) (xlist []*operand) {
call.go#L365: func (check *Checker) genericExprList(elist []ast.Expr) (resList []*operand, targsList [][]Type) {
call.go#L462: func (check *Checker) arguments(call *ast.CallExpr, sig *Signature, targs []Type, xlist []ast.Expr, args []*operand, atargs [][]Type) (rsig *Signature) {
call.go#L716: check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", ast.Expr(e)) // cast to ast.Expr to silence vet
call.go#L729: check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s (but have %s)", ast.Expr(e), exps[0].Name())
call.go#L731: check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", ast.Expr(e))
call.go#L811: check.errorf(e.Sel, NotAType, "%s is not a type", ast.Expr(e))
call.go#L990: func (check *Checker) use(args ...ast.Expr) bool { return check.useN(args, false) }
call.go#L995: func (check *Checker) useLHS(args ...ast.Expr) bool { return check.useN(args, true) }
call.go#L997: func (check *Checker) useN(args []ast.Expr, lhs bool) bool {
call.go#L1007: func (check *Checker) use1(e ast.Expr, lhs bool) bool {
check.go#L195: untyped map[ast.Expr]exprInfo // map of expressions without final type
check.go#L249: func (check *Checker) rememberUntyped(e ast.Expr, lhs bool, mode operandMode, typ *Basic, val constant.Value) {
check.go#L252: m = make(map[ast.Expr]exprInfo)
check.go#L605: func (check *Checker) recordTypeAndValueInSyntax(x ast.Expr, mode operandMode, typ Type, val constant.Value) {
check.go#L611: func (check *Checker) recordCommaOkTypesInSyntax(x ast.Expr, t0, t1 Type) {
check.go#L617: func instantiatedIdent(expr ast.Expr) *ast.Ident {
check.go#L618: var selOrIdent ast.Expr
decl.go#L378: typ ast.Expr
decl.go#L379: init []ast.Expr
decl.go#L443: func (check *Checker) constDecl(obj *Const, typ, init ast.Expr, inherited bool) {
decl.go#L489: func (check *Checker) varDecl(obj *Var, lhs []*Var, typ, init ast.Expr) {
decl.go#L539: check.initVars(lhs, []ast.Expr{init}, nil)
decl.go#L722: func (check *Checker) bound(x ast.Expr) Type {
decl.go#L898: var init ast.Expr
decl.go#L929: var init ast.Expr
eval.go#L32: Types: make(map[ast.Expr]TypeAndValue),
eval.go#L56: func CheckExpr(fset *token.FileSet, pkg *Package, pos token.Pos, expr ast.Expr, info *Info) (err error) {
expr.go#L88: func opPos(x ast.Expr) token.Pos {
expr.go#L101: func opName(e ast.Expr) string {
expr.go#L260: func (check *Checker) updateExprType(x ast.Expr, typ Type, final bool) {
expr.go#L374: func (check *Checker) updateExprVal(x ast.Expr, val constant.Value) {
expr.go#L617: func (check *Checker) shift(x, y *operand, e ast.Expr, op token.Token) {
expr.go#L779: func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token.Token, opPos token.Pos) {
expr.go#L968: func (check *Checker) rawExpr(T *target, x *operand, e ast.Expr, hint Type, allowGeneric bool) exprKind {
expr.go#L1021: func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type) exprKind {
expr.go#L1232: func (check *Checker) typeAssertion(e ast.Expr, x *operand, T Type, typeSwitch bool) {
expr.go#L1251: func (check *Checker) expr(T *target, x *operand, e ast.Expr) {
expr.go#L1258: func (check *Checker) genericExpr(x *operand, e ast.Expr) {
expr.go#L1269: func (check *Checker) multiExpr(e ast.Expr, allowCommaOk bool) (list []*operand, commaOk bool) {
expr.go#L1300: func (check *Checker) exprWithHint(x *operand, e ast.Expr, hint Type) {
expr.go#L1311: func (check *Checker) exprOrType(x *operand, e ast.Expr, allowGeneric bool) {
exprstring.go#L18: func ExprString(x ast.Expr) string {
exprstring.go#L27: func WriteExpr(buf *bytes.Buffer, x ast.Expr) {
exprstring.go#L230: func writeExprList(buf *bytes.Buffer, list []ast.Expr) {
format.go#L31: case ast.Expr:
format.go#L33: case []ast.Expr:
index.go#L327: for i, expr := range []ast.Expr{e.Low, e.High, e.Max} {
index.go#L361: at := []ast.Expr{e.Low, e.High, e.Max}[i+1+j]
index.go#L373: func (check *Checker) singleIndex(expr *indexedExpr) ast.Expr {
index.go#L389: func (check *Checker) index(index ast.Expr, max int64) (typ Type, val int64) {
index.go#L462: orig ast.Expr // the wrapped expr, which may be distinct from the IndexListExpr below.
index.go#L463: x ast.Expr // expression
index.go#L465: indices []ast.Expr // index expressions
index.go#L480: indices: []ast.Expr{e.Index},
literals.go#L354: func (check *Checker) indexedElts(elts []ast.Expr, typ Type, length int64) int64 {
mono.go#L176: func (w *monoGraph) recordInstance(pkg *Package, pos token.Pos, tparams []*TypeParam, targs []Type, xlist []ast.Expr) {
operand.go#L61: expr ast.Expr
range.go#L27: func (check *Checker) rangeStmt(inner stmtContext, rangeStmt *ast.RangeStmt, noNewVarPos positioner, sKey, sValue, sExtra, rangeVar ast.Expr, isDef bool) {
range.go#L96: lhs := [2]ast.Expr{sKey, sValue} // sKey, sValue may be nil
recording.go#L59: func (check *Checker) recordTypeAndValue(x ast.Expr, mode operandMode, typ Type, val constant.Value) {
recording.go#L77: func (check *Checker) recordBuiltinType(f ast.Expr, sig *Signature) {
recording.go#L97: func (check *Checker) recordCommaOkTypes(x ast.Expr, a []*operand) {
recording.go#L132: func (check *Checker) recordInstance(expr ast.Expr, targs []Type, typ Type) {
resolver.go#L25: vtyp ast.Expr // type, or nil (for const and var declarations only)
resolver.go#L26: init ast.Expr // init/orig expression, or nil (for const and var declarations only)
resolver.go#L357: var init ast.Expr
resolver.go#L388: var init ast.Expr
resolver.go#L511: func (check *Checker) unpackRecv(rtyp ast.Expr, unpackParams bool) (ptr bool, base ast.Expr, tparams []*ast.Ident) {
signature.go#L352: func (check *Checker) recordParenthesizedRecvTypes(expr ast.Expr, typ Type) {
stmt.go#L237: func (check *Checker) caseValues(x *operand, values []ast.Expr, seen valueMap) {
stmt.go#L277: func (check *Checker) isNil(e ast.Expr) bool {
stmt.go#L307: func (check *Checker) caseTypes(x *operand, types []ast.Expr, seen map[Type]ast.Expr) Type {
stmt.go#L359: func (check *Checker) caseTypes_currently_unused(x *operand, xtyp *Interface, types []ast.Expr, seen map[string]ast.Expr) Type {
stmt.go#L689: var rhs ast.Expr
stmt.go#L745: seen := make(map[Type]ast.Expr) // map of seen types to positions
stmt.go#L799: var rhs ast.Expr // rhs of RecvStmt, or nil
struct.go#L181: func embeddedFieldIdent(e ast.Expr) *ast.Ident {
typexpr.go#L150: func (check *Checker) typ(e ast.Expr) Type {
typexpr.go#L157: func (check *Checker) varType(e ast.Expr) Type {
typexpr.go#L165: func (check *Checker) validVarType(e ast.Expr, typ Type) {
typexpr.go#L192: func (check *Checker) definedType(e ast.Expr, def *TypeName) Type {
typexpr.go#L210: func (check *Checker) genericType(e ast.Expr, cause *string) Type {
typexpr.go#L232: func (check *Checker) typInternal(e0 ast.Expr, def *TypeName) (T Type) {
typexpr.go#L506: func (check *Checker) arrayLength(e ast.Expr) int64 {
typexpr.go#L554: func (check *Checker) typeList(list []ast.Expr) []Type {
union.go#L54: func parseUnion(check *Checker, uexpr ast.Expr) Type {
union.go#L139: func parseTilde(check *Checker, tx ast.Expr) *Term {
union.go#L193: func flattenUnion(list []ast.Expr, x ast.Expr) (blist, tlist []ast.Expr) {
golang.org/x/tools/go/packages
packages.go#L1187: Types: make(map[ast.Expr]types.TypeAndValue),
golang.org/x/tools/go/types/typeutil
callee.go#L52: func usedIdent(info *types.Info, e ast.Expr) *ast.Ident {
golang.org/x/tools/internal/typeparams
common.go#L30: func UnpackIndexExpr(n ast.Node) (x ast.Expr, lbrack token.Pos, indices []ast.Expr, rbrack token.Pos) {
common.go#L33: return e.X, e.Lbrack, []ast.Expr{e.Index}, e.Rbrack
common.go#L43: func PackIndexExpr(x ast.Expr, lbrack token.Pos, indices []ast.Expr, rbrack token.Pos) ast.Expr {
golang.org/x/tools/internal/typesinternal
classify_call.go#L129: func UsedIdent(info *types.Info, e ast.Expr) *ast.Ident {
classify_call.go#L134: func usedIdent(info *types.Info, e ast.Expr) *ast.Ident
types.go#L146: Types: map[ast.Expr]types.TypeAndValue{},
zerovalue.go#L127: func ZeroExpr(t types.Type, qual types.Qualifier) (_ ast.Expr, isValid bool) {
zerovalue.go#L186: Args: []ast.Expr{
zerovalue.go#L210: func IsZeroExpr(expr ast.Expr) bool {
zerovalue.go#L224: func TypeExpr(t types.Type, qual types.Qualifier) ast.Expr {
zerovalue.go#L316: var expr ast.Expr = ast.NewIdent(t.Obj().Name())
zerovalue.go#L328: var indices []ast.Expr
zerovalue.go#L364: var union ast.Expr
gotest.tools/v3/assert/cmp
result.go#L64: func (r templatedResult) FailureMessage(args []ast.Expr) string {
result.go#L85: func renderMessage(result templatedResult, args []ast.Expr) (string, error) {
result.go#L88: "callArg": func(index int) ast.Expr {
gotest.tools/v3/internal/assert
assert.go#L116: func boolFailureMessage(expr ast.Expr) (string, error) {
result.go#L65: FailureMessage(args []ast.Expr) string
result.go#L84: func filterPrintableExpr(args []ast.Expr) []ast.Expr {
result.go#L85: result := make([]ast.Expr, len(args))
result.go#L100: func isShortPrintableExpr(expr ast.Expr) bool {
result.go#L112: type argSelector func([]ast.Expr) []ast.Expr
result.go#L116: func ArgsAfterT(args []ast.Expr) []ast.Expr {
result.go#L126: func ArgsFromComparisonCall(args []ast.Expr) []ast.Expr {
result.go#L138: func ArgsAtZeroIndex(args []ast.Expr) []ast.Expr {
gotest.tools/v3/internal/source
source.go#L32: func CallExprArgs(stackIndex int) ([]ast.Expr, error) {
source.go#L93: func getCallExprArgs(fileset *token.FileSet, astFile ast.Node, line int) ([]ast.Expr, error) {
update.go#L161: func getIdentForExpectedValueArg(expr []ast.Expr) (int, *ast.Ident) {