cel-go icon indicating copy to clipboard operation
cel-go copied to clipboard

Support non-overlapping overload dispatch using function

Open jpbetz opened this issue 3 years ago • 1 comments

cel-go allows for dispatch either by function name or overload ID. For example, given

cel.Declarations(
  decls.NewFunction("isSorted",
    decls.NewParameterizedInstanceOverload("list_a_is_sorted_bool",
      []*exprpb.Type{decls.NewListType(paramA)},
      decls.Bool, typeParamAList),
),

What works:

CEL will dispatch to functions.Overload{Operator: "list_a_is_sorted_bool"...} if it is declared in ProgramOptions otherwise it will dispatch to "isSorted".

What doesn't work:

If two cel.Functions() are registered that both declare "isSorted", CEL will report that the function name is already in use when the 2nd Functions are registered.

Proposal: If the two Functions declare non-overlapping overloads, allow them both to be registered using function name.

jpbetz avatar Feb 23 '22 21:02 jpbetz

This has been updated for all extension functions, but has yet to be implemented for all of the standard operators, including type conversion methods which I think are essential for ensuring that non-standard types can be converted into standard ones.

TristonianJones avatar Jul 06 '22 20:07 TristonianJones