MCPcopy Create free account
hub / github.com/dolthub/doltgresql / TypeCheck

Method TypeCheck

postgres/parser/sem/tree/type_check.go:1053–1070  ·  view source on GitHub ↗

TypeCheck implements the Expr interface.

(
	ctx context.Context, semaCtx *SemaContext, desired *types.T,
)

Source from the content-addressed store, hash-verified

1051
1052// TypeCheck implements the Expr interface.
1053func (expr *IfExpr) TypeCheck(
1054 ctx context.Context, semaCtx *SemaContext, desired *types.T,
1055) (TypedExpr, error) {
1056 typedCond, err := typeCheckAndRequireBoolean(ctx, semaCtx, expr.Cond, "IF condition")
1057 if err != nil {
1058 return nil, err
1059 }
1060
1061 typedSubExprs, retType, err := TypeCheckSameTypedExprs(ctx, semaCtx, desired, expr.True, expr.Else)
1062 if err != nil {
1063 return nil, decorateTypeCheckError(err, "incompatible IF expressions")
1064 }
1065
1066 expr.Cond = typedCond
1067 expr.True, expr.Else = typedSubExprs[0], typedSubExprs[1]
1068 expr.typ = retType
1069 return expr, nil
1070}
1071
1072// TypeCheck implements the Expr interface.
1073func (expr *IsOfTypeExpr) TypeCheck(

Callers

nothing calls this directly

Calls 3

TypeCheckSameTypedExprsFunction · 0.85
decorateTypeCheckErrorFunction · 0.85

Tested by

no test coverage detected