| 82 | const FunctionDoc& FunctionDoc::Empty() { return kEmptyFunctionDoc; } |
| 83 | |
| 84 | static Status CheckArityImpl(const Function& func, int num_args) { |
| 85 | if (func.arity().is_varargs && num_args < func.arity().num_args) { |
| 86 | return Status::Invalid("VarArgs function '", func.name(), "' needs at least ", |
| 87 | func.arity().num_args, " arguments but only ", num_args, |
| 88 | " passed"); |
| 89 | } |
| 90 | |
| 91 | if (!func.arity().is_varargs && num_args != func.arity().num_args) { |
| 92 | return Status::Invalid("Function '", func.name(), "' accepts ", func.arity().num_args, |
| 93 | " arguments but ", num_args, " passed"); |
| 94 | } |
| 95 | return Status::OK(); |
| 96 | } |
| 97 | |
| 98 | Status Function::CheckArity(size_t num_args) const { |
| 99 | return CheckArityImpl(*this, static_cast<int>(num_args)); |
no test coverage detected