Skip to content

Commit 76e104d

Browse files
committed
Merge pull request googollee#96 from johnwchadwick/master
Move argument check so that too many arguments does not panic.
2 parents 647d8ca + b14926c commit 76e104d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

caller.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ func (c *caller) Call(so Socket, args []interface{}) []reflect.Value {
6161
} else {
6262
a = make([]reflect.Value, len(args))
6363
}
64+
65+
if len(args) != len(c.Args) {
66+
return []reflect.Value{reflect.ValueOf([]interface{}{}), reflect.ValueOf(errors.New("Arguments do not match"))}
67+
}
68+
6469
for i, arg := range args {
6570
v := reflect.ValueOf(arg)
6671
if c.Args[i].Kind() != reflect.Ptr {
@@ -73,9 +78,5 @@ func (c *caller) Call(so Socket, args []interface{}) []reflect.Value {
7378
a[i+diff] = v
7479
}
7580

76-
if len(args) != len(c.Args) {
77-
return []reflect.Value{reflect.ValueOf([]interface{}{}), reflect.ValueOf(errors.New("Arguments do not match"))}
78-
}
79-
8081
return c.Func.Call(a)
8182
}

0 commit comments

Comments
 (0)