Skip to content

Commit 647ee3b

Browse files
Ensure stable ordering of overload candidates (#816) (#818)
1 parent e517cf5 commit 647ee3b

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

‎cel/cel_test.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1944,7 +1944,8 @@ func TestDynamicDispatch(t *testing.T) {
19441944
),
19451945
)
19461946
out, err := interpret(t, env, `
1947-
[1, 2].first() == 1
1947+
[].first() == 0
1948+
&& [1, 2].first() == 1
19481949
&& [1.0, 2.0].first() == 1.0
19491950
&& ["hello", "world"].first() == "hello"
19501951
&& [["hello"], ["world", "!"]].first().first() == "hello"

‎common/decls/decls.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ func (f *FunctionDecl) Bindings() ([]*functions.Overload, error) {
243243
// performs dynamic dispatch to the proper overload based on the argument types.
244244
bindings := append([]*functions.Overload{}, overloads...)
245245
funcDispatch := func(args ...ref.Val) ref.Val {
246-
for _, o := range f.overloads {
246+
for _, oID := range f.overloadOrdinals {
247+
o := f.overloads[oID]
247248
// During dynamic dispatch over multiple functions, signature agreement checks
248249
// are preserved in order to assist with the function resolution step.
249250
switch len(args) {

0 commit comments

Comments
 (0)