Bump cel-go to v0.12.1

This commit is contained in:
Cici Huang
2022-07-11 17:05:02 +00:00
parent 772a252b06
commit a421fd4834
9 changed files with 23 additions and 15 deletions

View File

@@ -165,7 +165,7 @@ type Type struct {
isAssignableRuntimeType func(other ref.Type) bool
}
// IsAssignableFrom determines whether the current type is type-check assignable from the input fromType.
// IsAssignableType determines whether the current type is type-check assignable from the input fromType.
func (t *Type) IsAssignableType(fromType *Type) bool {
if t.isAssignableType != nil {
return t.isAssignableType(fromType)
@@ -650,7 +650,7 @@ func (f *functionDecl) merge(other *functionDecl) (*functionDecl, error) {
for _, o := range other.overloads {
err := merged.addOverload(o)
if err != nil {
return nil, fmt.Errorf("function declration merge failed: %v", err)
return nil, fmt.Errorf("function declaration merge failed: %v", err)
}
}
if other.singleton != nil {
@@ -821,8 +821,8 @@ func (o *overloadDecl) signatureOverlaps(other *overloadDecl) bool {
for i, argType := range o.argTypes {
otherArgType := other.argTypes[i]
argsOverlap = argsOverlap &&
(argType.IsAssignableRuntimeType(otherArgType.runtimeType) ||
otherArgType.IsAssignableRuntimeType(argType.runtimeType))
(argType.IsAssignableType(otherArgType) ||
otherArgType.IsAssignableType(argType))
}
return argsOverlap
}

View File

@@ -61,6 +61,8 @@ func (ast *Ast) SourceInfo() *exprpb.SourceInfo {
// ResultType returns the output type of the expression if the Ast has been type-checked, else
// returns decls.Dyn as the parse step cannot infer the type.
//
// Deprecated: use OutputType
func (ast *Ast) ResultType() *exprpb.Type {
if !ast.IsChecked() {
return decls.Dyn
@@ -68,6 +70,8 @@ func (ast *Ast) ResultType() *exprpb.Type {
return ast.typeMap[ast.expr.GetId()]
}
// OutputType returns the output type of the expression if the Ast has been type-checked, else
// returns cel.DynType as the parse step cannot infer types.
func (ast *Ast) OutputType() *Type {
t, err := ExprTypeToType(ast.ResultType())
if err != nil {

View File

@@ -20,6 +20,10 @@ import (
exprpb "google.golang.org/genproto/googleapis/api/expr/v1alpha1"
)
// Macro describes a function signature to match and the MacroExpander to apply.
//
// Note: when a Macro should apply to multiple overloads (based on arg count) of a given function,
// a Macro should be created per arg-count or as a var arg macro.
type Macro = parser.Macro
// MacroExpander converts a call and its associated arguments into a new CEL abstract syntax tree, or an error
@@ -85,7 +89,7 @@ func MapMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.E
return parser.MakeMap(meh, target, args)
}
// MakeFilter expands the input call arguments into a comprehension which produces a list which contains
// FilterMacroExpander expands the input call arguments into a comprehension which produces a list which contains
// only elements which match the provided predicate expression:
// <iterRange>.filter(<iterVar>, <predicate>)
func FilterMacroExpander(meh MacroExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *common.Error) {

View File

@@ -284,7 +284,7 @@ const (
quantifierExistsOne
)
// MakeExists expands the input call arguments into a comprehension that returns true if all of the
// MakeAll expands the input call arguments into a comprehension that returns true if all of the
// elements in the range match the predicate expressions:
// <iterRange>.all(<iterVar>, <predicate>)
func MakeAll(eh ExprHelper, target *exprpb.Expr, args []*exprpb.Expr) (*exprpb.Expr, *common.Error) {