MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / NewTypedUnaryExpr

Function NewTypedUnaryExpr

pkg/sql/sem/tree/expr.go:1239–1255  ·  view source on GitHub ↗

NewTypedUnaryExpr returns a new UnaryExpr that is well-typed.

(op UnaryOperator, expr TypedExpr, typ *types.T)

Source from the content-addressed store, hash-verified

1237
1238// NewTypedUnaryExpr returns a new UnaryExpr that is well-typed.
1239func NewTypedUnaryExpr(op UnaryOperator, expr TypedExpr, typ *types.T) *UnaryExpr {
1240 node := &UnaryExpr{Operator: op, Expr: expr}
1241 node.typ = typ
1242 innerType := expr.ResolvedType()
1243
1244 _ = UnaryOps[op.Symbol].ForEachUnaryOp(func(o *UnaryOp) error {
1245 if innerType.Equivalent(o.Typ) && node.typ.Equivalent(o.ReturnType) {
1246 node.op = o
1247 return iterutil.StopIteration()
1248 }
1249 return nil
1250 })
1251 if node.op == nil {
1252 panic(errors.AssertionFailedf("invalid TypedExpr with unary op %d: %s", op.Symbol, expr))
1253 }
1254 return node
1255}
1256
1257// FuncExpr represents a function call.
1258type FuncExpr struct {

Callers

nothing calls this directly

Calls 4

StopIterationFunction · 0.92
ForEachUnaryOpMethod · 0.80
EquivalentMethod · 0.80
ResolvedTypeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…