Skip to content

Commit

Permalink
Ensure stable ordering of overload candidates during dynamic dispatch (
Browse files Browse the repository at this point in the history
  • Loading branch information
TristonianJones authored Aug 19, 2023
1 parent 1a6373d commit 2de9952
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cel/cel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,8 @@ func TestDynamicDispatch(t *testing.T) {
),
)
out, err := interpret(t, env, `
[1, 2].first() == 1
dyn([]).first() == 0
&& [1, 2].first() == 1
&& [1.0, 2.0].first() == 1.0
&& ["hello", "world"].first() == "hello"
&& [["hello"], ["world", "!"]].first().first() == "hello"
Expand Down
3 changes: 2 additions & 1 deletion common/decls/decls.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ func (f *FunctionDecl) Bindings() ([]*functions.Overload, error) {
// performs dynamic dispatch to the proper overload based on the argument types.
bindings := append([]*functions.Overload{}, overloads...)
funcDispatch := func(args ...ref.Val) ref.Val {
for _, o := range f.overloads {
for _, oID := range f.overloadOrdinals {
o := f.overloads[oID]
// During dynamic dispatch over multiple functions, signature agreement checks
// are preserved in order to assist with the function resolution step.
switch len(args) {
Expand Down

0 comments on commit 2de9952

Please sign in to comment.