Skip to content

Commit

Permalink
feat: evalCall now also supports data.Value parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasjarosch committed May 1, 2024
1 parent bcb5a62 commit 45b8b8d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion expression/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,19 @@ func (s *state) evalCall(call *CallNode) (reflect.Value, error) {
// except in cases where argType is interface{}
if argType.Kind() != reflect.Interface {
if argType.Kind() != argValue.Kind() {
s.errorf("%s expected %s got %s", ErrIncompatibleArgType, argType.Kind(), argValue.Kind())

// it may very well be that, at this point, the argValue is a `data.Value`
// because it is the result of an expression which was executed prior to this one
dataValue, ok := argValue.Interface().(data.Value)
if !ok {
s.errorf("%s expected %s; got %s", ErrIncompatibleArgType, argType.Kind(), argValue.Kind())
}
if reflect.TypeOf(dataValue.Raw) == argType {
argValue = reflect.ValueOf(dataValue.Raw)
} else {
s.errorf("%s (data.Value) expected %s; got %s", ErrIncompatibleArgType, argType.Kind(), argValue.Kind())
}

}
}

Expand Down

0 comments on commit 45b8b8d

Please sign in to comment.