TypeCheck implements the Expr interface.
( ctx context.Context, semaCtx *SemaContext, desired *types.T, )
| 468 | |
| 469 | // TypeCheck implements the Expr interface. |
| 470 | func (expr *IndirectionExpr) TypeCheck( |
| 471 | ctx context.Context, semaCtx *SemaContext, desired *types.T, |
| 472 | ) (TypedExpr, error) { |
| 473 | for i, t := range expr.Indirection { |
| 474 | if t.Slice { |
| 475 | return nil, unimplemented.NewWithIssuef(32551, "ARRAY slicing in %s", expr) |
| 476 | } |
| 477 | if i > 0 { |
| 478 | return nil, unimplemented.NewWithIssueDetailf(32552, "ind", "multidimensional indexing: %s", expr) |
| 479 | } |
| 480 | |
| 481 | beginExpr, err := typeCheckAndRequire(ctx, semaCtx, t.Begin, types.Int, "ARRAY subscript") |
| 482 | if err != nil { |
| 483 | return nil, err |
| 484 | } |
| 485 | t.Begin = beginExpr |
| 486 | } |
| 487 | |
| 488 | subExpr, err := expr.Expr.TypeCheck(ctx, semaCtx, types.MakeArray(desired)) |
| 489 | if err != nil { |
| 490 | return nil, err |
| 491 | } |
| 492 | typ := subExpr.ResolvedType() |
| 493 | if typ.Family() != types.ArrayFamily { |
| 494 | return nil, pgerror.Newf(pgcode.DatatypeMismatch, "cannot subscript type %s because it is not an array", typ) |
| 495 | } |
| 496 | expr.Expr = subExpr |
| 497 | expr.typ = typ.ArrayContents() |
| 498 | |
| 499 | return expr, nil |
| 500 | } |
| 501 | |
| 502 | // TypeCheck implements the Expr interface. |
| 503 | func (expr *AnnotateTypeExpr) TypeCheck( |
nothing calls this directly
no test coverage detected