function.go: removed useless param != nil check

This commit is contained in:
Celestino Amoroso 2024-07-07 15:58:29 +02:00
parent 8051faa2bf
commit 6834d9f47b

View File

@ -112,25 +112,24 @@ type funcInfo struct {
func newFuncInfo(name string, functor Functor, returnType string, params []ExprFuncParam) (info *funcInfo, err error) { func newFuncInfo(name string, functor Functor, returnType string, params []ExprFuncParam) (info *funcInfo, err error) {
var minArgs = 0 var minArgs = 0
var maxArgs = 0 var maxArgs = 0
if params != nil { for _, p := range params {
for _, p := range params { if maxArgs == -1 {
if maxArgs == -1 { return nil, fmt.Errorf("no more params can be specified after the ellipsis symbol: %q", p.Name())
return nil, fmt.Errorf("no more params can be specified after the ellipsis symbol: %q", p.Name()) }
} if p.IsDefault() || p.IsOptional() {
if p.IsDefault() || p.IsOptional() { maxArgs++
maxArgs++ } else if maxArgs == minArgs {
} else if maxArgs == minArgs { minArgs++
minArgs++ maxArgs++
maxArgs++ } else {
} else { return nil, fmt.Errorf("can't specify non-optional param after optional ones: %q", p.Name())
return nil, fmt.Errorf("can't specify non-optional param after optional ones: %q", p.Name()) }
} if p.IsRepeat() {
if p.IsRepeat() { minArgs--
minArgs-- maxArgs = -1
maxArgs = -1
}
} }
} }
info = &funcInfo{ info = &funcInfo{
name: name, minArgs: minArgs, maxArgs: maxArgs, functor: functor, returnType: returnType, formalParams: params, name: name, minArgs: minArgs, maxArgs: maxArgs, functor: functor, returnType: returnType, formalParams: params,
} }