operand-func.go: improved error report when functions reveive less params than expected
This commit is contained in:
parent
43b74131fb
commit
a9d6a82011
@ -25,7 +25,11 @@ func newFuncCallTerm(tk *Token, args []*term) *term {
|
|||||||
func checkFunctionCall(ctx ExprContext, name string, params []any) (err error) {
|
func checkFunctionCall(ctx ExprContext, name string, params []any) (err error) {
|
||||||
if info, exists := ctx.GetFuncInfo(name); exists {
|
if info, exists := ctx.GetFuncInfo(name); exists {
|
||||||
if info.MinArgs() > len(params) {
|
if info.MinArgs() > len(params) {
|
||||||
err = fmt.Errorf("too few params -- expected %d, got %d", info.MinArgs(), len(params))
|
if info.MaxArgs() < 0 {
|
||||||
|
err = fmt.Errorf("too few params -- expected %d or more, got %d", info.MinArgs(), len(params))
|
||||||
|
} else {
|
||||||
|
err = fmt.Errorf("too few params -- expected %d, got %d", info.MinArgs(), len(params))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if info.MaxArgs() >= 0 && info.MaxArgs() < len(params) {
|
if info.MaxArgs() >= 0 && info.MaxArgs() < len(params) {
|
||||||
err = fmt.Errorf("too much params -- expected %d, got %d", info.MaxArgs(), len(params))
|
err = fmt.Errorf("too much params -- expected %d, got %d", info.MaxArgs(), len(params))
|
||||||
|
Loading…
Reference in New Issue
Block a user