From 6834d9f47bdf589bf1728c4a716e0904c95f0c09 Mon Sep 17 00:00:00 2001 From: Celestino Amoroso Date: Sun, 7 Jul 2024 15:58:29 +0200 Subject: [PATCH] function.go: removed useless param != nil check --- function.go | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/function.go b/function.go index 9d1c4b3..68a184f 100644 --- a/function.go +++ b/function.go @@ -112,25 +112,24 @@ type funcInfo struct { func newFuncInfo(name string, functor Functor, returnType string, params []ExprFuncParam) (info *funcInfo, err error) { var minArgs = 0 var maxArgs = 0 - if params != nil { - for _, p := range params { - if maxArgs == -1 { - return nil, fmt.Errorf("no more params can be specified after the ellipsis symbol: %q", p.Name()) - } - if p.IsDefault() || p.IsOptional() { - maxArgs++ - } else if maxArgs == minArgs { - minArgs++ - maxArgs++ - } else { - return nil, fmt.Errorf("can't specify non-optional param after optional ones: %q", p.Name()) - } - if p.IsRepeat() { - minArgs-- - maxArgs = -1 - } + for _, p := range params { + if maxArgs == -1 { + return nil, fmt.Errorf("no more params can be specified after the ellipsis symbol: %q", p.Name()) + } + if p.IsDefault() || p.IsOptional() { + maxArgs++ + } else if maxArgs == minArgs { + minArgs++ + maxArgs++ + } else { + return nil, fmt.Errorf("can't specify non-optional param after optional ones: %q", p.Name()) + } + if p.IsRepeat() { + minArgs-- + maxArgs = -1 } } + info = &funcInfo{ name: name, minArgs: minArgs, maxArgs: maxArgs, functor: functor, returnType: returnType, formalParams: params, }