Skip to content

Commit

Permalink
fix panic when arity is unlimited and there is no argument
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziine committed Nov 21, 2023
1 parent 8422929 commit 31c0128
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/expr/functions/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func (fd *definition) Name() string {
}

func (fd *definition) Function(args ...expr.Expr) (expr.Function, error) {
if fd.arity == UNLIMITED && len(args) == 0 {
return nil, fmt.Errorf("%s() requires at least one argument", fd.name)

Check warning on line 64 in internal/expr/functions/definition.go

View check run for this annotation

Codecov / codecov/patch

internal/expr/functions/definition.go#L64

Added line #L64 was not covered by tests
}
if fd.arity != UNLIMITED && (len(args) != fd.arity) {
return nil, fmt.Errorf("%s() takes %d argument(s), not %d", fd.name, fd.arity, len(args))
}
Expand Down

0 comments on commit 31c0128

Please sign in to comment.