Fix error for vararg functions with zero arguments

This commit is contained in:
Fabian Boehm 2022-09-08 20:45:20 +02:00
parent c284c4ca99
commit 24fd26ae6e
2 changed files with 8 additions and 1 deletions

View File

@ -461,7 +461,9 @@ double state::base() {
if (type_ != TOK_ERROR || error_ == TE_ERROR_UNEXPECTED_TOKEN) {
// Otherwise we complain about the number of arguments *first*,
// a closing parenthesis should be more obvious.
error_ = i < arity ? TE_ERROR_TOO_FEW_ARGS : TE_ERROR_TOO_MANY_ARGS;
//
// Vararg functions need at least one argument.
error_ = (i < arity || (arity == -1 && i == 0)) ? TE_ERROR_TOO_FEW_ARGS : TE_ERROR_TOO_MANY_ARGS;
type_ = TOK_ERROR;
if (first_err) {
errpos_ = first_err;

View File

@ -109,6 +109,11 @@ not math 'ncr(1)'
# CHECKERR: 'ncr(1)'
# CHECKERR: ^
math "min()"
# CHECKERR: math: Error: Too few arguments
# CHECKERR: 'min()'
# CHECKERR: ^
# There is no "blah" function.
not math 'blah()'
# CHECKERR: math: Error: Unknown function