| 645 | } |
| 646 | |
| 647 | func (expr *Tuple) normalize(v *NormalizeVisitor) TypedExpr { |
| 648 | // A Tuple should be directly evaluated into a DTuple if it's either fully |
| 649 | // constant or contains only constants and top-level Placeholders. |
| 650 | isConst := true |
| 651 | for _, subExpr := range expr.Exprs { |
| 652 | if !v.isConst(subExpr) { |
| 653 | isConst = false |
| 654 | break |
| 655 | } |
| 656 | } |
| 657 | if !isConst { |
| 658 | return expr |
| 659 | } |
| 660 | e, err := expr.Eval(v.ctx) |
| 661 | if err != nil { |
| 662 | v.err = err |
| 663 | } |
| 664 | return e |
| 665 | } |
| 666 | |
| 667 | // NormalizeExpr normalizes a typed expression, simplifying where possible, |
| 668 | // but guaranteeing that the result of evaluating the expression is |