mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-15 07:05:50 +01:00
Fix for variadic args in bound methods
This commit is contained in:
parent
4165caa02e
commit
42fb91bc73
1 changed files with 11 additions and 3 deletions
|
|
@ -239,14 +239,22 @@ func (b *BoundMethod) Call(args []interface{}) (interface{}, error) {
|
|||
// Check inputs
|
||||
expectedInputLength := len(b.Inputs)
|
||||
actualInputLength := len(args)
|
||||
if expectedInputLength != actualInputLength {
|
||||
return nil, fmt.Errorf("%s takes %d inputs. Received %d", b.Name, expectedInputLength, actualInputLength)
|
||||
|
||||
// If the method is variadic, we need to check the minimum number of inputs
|
||||
if b.Method.Type().IsVariadic() {
|
||||
if actualInputLength < expectedInputLength-1 {
|
||||
return nil, fmt.Errorf("%s takes at least %d inputs. Received %d", b.Name, expectedInputLength, actualInputLength)
|
||||
}
|
||||
} else {
|
||||
if expectedInputLength != actualInputLength {
|
||||
return nil, fmt.Errorf("%s takes %d inputs. Received %d", b.Name, expectedInputLength, actualInputLength)
|
||||
}
|
||||
}
|
||||
|
||||
/** Convert inputs to reflect values **/
|
||||
|
||||
// Create slice for the input arguments to the method call
|
||||
callArgs := make([]reflect.Value, expectedInputLength)
|
||||
callArgs := make([]reflect.Value, actualInputLength)
|
||||
|
||||
// Iterate over given arguments
|
||||
for index, arg := range args {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue