Skip to content

Commit

Permalink
Merge pull request #109 from KinyaElGrande/fix-function-nil-args
Browse files Browse the repository at this point in the history
Fix functions Nil arguements
  • Loading branch information
generikvault authored Nov 28, 2024
2 parents 9162467 + 1dc0fee commit 8faea0d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func createCallArguments(ctx context.Context, t reflect.Type, args []interface{}
}
argVal := reflect.ValueOf(arg)
if arg == nil {
argVal = reflect.ValueOf(reflect.Interface)
argVal = reflect.Zero(reflect.TypeOf((*interface{})(nil)).Elem())
} else if !argVal.Type().AssignableTo(inType) {
return nil, fmt.Errorf("expected type %s for parameter %d but got %T",
inType.String(), i, arg)
Expand Down
2 changes: 1 addition & 1 deletion functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func Test_toFunc(t *testing.T) {
{
name: "nil arg",
function: func(a interface{}) bool {
return a != nil
return a == nil
},
arguments: []interface{}{nil},
want: true,
Expand Down

0 comments on commit 8faea0d

Please sign in to comment.