Skip to content

Commit 2de9952

Browse files
Ensure stable ordering of overload candidates during dynamic dispatch (#817)
1 parent 1a6373d commit 2de9952

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
@@ -2081,7 +2081,8 @@ func TestDynamicDispatch(t *testing.T) {
20812081
),
20822082
)
20832083
out, err := interpret(t, env, `
2084-
[1, 2].first() == 1
2084+
dyn([]).first() == 0
2085+
&& [1, 2].first() == 1
20852086
&& [1.0, 2.0].first() == 1.0
20862087
&& ["hello", "world"].first() == "hello"
20872088
&& [["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)