Skip to content

Commit f6d62cb

Browse files
authored
Merge branch 'unstable' into feature/3359-cf-exists
2 parents 30d04d4 + b04211e commit f6d62cb

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

src/commands/cmd_function.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ struct CommandFCall : Commander {
100100
int64_t numkeys = GET_OR_RET(ParseInt<int64_t>(args_[2], 10));
101101
if (numkeys > int64_t(args_.size() - 3)) {
102102
return {Status::NotOK, "Number of keys can't be greater than number of args"};
103-
} else if (numkeys < -1) {
103+
} else if (numkeys < 0) {
104104
return {Status::NotOK, "Number of keys can't be negative"};
105105
}
106106

tests/gocase/unit/scripting/function_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@ var testFunctions = func(t *testing.T, config util.KvrocksServerConfigs) {
136136
require.Error(t, rdb.Do(ctx, "FUNCTION", "LOAD", code2).Err(), "ERR Library names can only contain letters, numbers, or underscores(_) and must be at least one character long")
137137
})
138138

139+
t.Run("FCALL - numkeys can't be negative", func(t *testing.T) {
140+
util.ErrorRegexp(t, rdb.Do(ctx, "FCALL", "inc", -1).Err(), ".*can't be negative.*")
141+
util.ErrorRegexp(t, rdb.Do(ctx, "FCALL_RO", "inc", -1).Err(), ".*can't be negative.*")
142+
})
143+
139144
t.Run("FUNCTION LOAD and FCALL mylib1", func(t *testing.T) {
140145
util.ErrorRegexp(t, rdb.Do(ctx, "FCALL", "inc", 0, 1).Err(), ".*No such function name.*")
141146
require.NoError(t, rdb.Do(ctx, "FUNCTION", "LOAD", luaMylib1).Err())

0 commit comments

Comments
 (0)