Skip to content
Snippets Groups Projects
Commit 298eebf7 authored by AnastasMIPT's avatar AnastasMIPT Committed by Nikita Pettik
Browse files

lua: fix bug with discarding arguments in box.func:call()

Fixes incorrect handling of variable number of arguments in box.func:call().

Closes #6405
parent cd675879
No related branches found
No related tags found
No related merge requests found
## bugfix/lua
* Fixed incorrect handling of variable number of arguments in box.func:call() (gh-6405).
......@@ -2663,7 +2663,7 @@ func_mt.call = function(func, args)
if type(args) ~= 'table' then
error('Use func:call(table)')
end
return box.schema.func.call(func.name, unpack(args))
return box.schema.func.call(func.name, unpack(args, 1, table.maxn(args)))
end
function box.schema.func.bless(func)
......
-- test-run result file version 2
args_type = function(...) \
local type_table = {} \
for i = 1, select('#', ...) do \
type_table[i] = type(select(i, ...)) \
end \
return type_table \
end \
box.schema.func.create('args_type')
| ---
| ...
box_call = box.func.args_type:call({1, nil, 3})
| ---
| ...
lua_call = args_type(1, nil, 3)
| ---
| ...
assert(table.equals(box_call, lua_call))
| ---
| - true
| ...
box_call = box.func.args_type:call({'string', nil, 3})
| ---
| ...
lua_call = args_type('string', nil, 3)
| ---
| ...
assert(table.equals(box_call, lua_call))
| ---
| - true
| ...
box_call = box.func.args_type:call({1, nil, 7, nil, 3, 5, nil, 9, 10})
| ---
| ...
lua_call = args_type(1, nil, 7, nil, 3, 5, nil, 9, 10)
| ---
| ...
assert(table.equals(box_call, lua_call))
| ---
| - true
| ...
box_call = box.func.args_type:call({1, 2, 3, 'string'})
| ---
| ...
lua_call = args_type(1, 2, 3, 'string')
| ---
| ...
assert(table.equals(box_call, lua_call))
| ---
| - true
| ...
box_call = box.func.args_type:call({nil, nil, 3})
| ---
| ...
lua_call = args_type(nil, nil, 3)
| ---
| ...
assert(table.equals(box_call, lua_call))
| ---
| - true
| ...
box.schema.func.drop('args_type')
| ---
| ...
args_type = function(...) \
local type_table = {} \
for i = 1, select('#', ...) do \
type_table[i] = type(select(i, ...)) \
end \
return type_table \
end \
box.schema.func.create('args_type')
box_call = box.func.args_type:call({1, nil, 3})
lua_call = args_type(1, nil, 3)
assert(table.equals(box_call, lua_call))
box_call = box.func.args_type:call({'string', nil, 3})
lua_call = args_type('string', nil, 3)
assert(table.equals(box_call, lua_call))
box_call = box.func.args_type:call({1, nil, 7, nil, 3, 5, nil, 9, 10})
lua_call = args_type(1, nil, 7, nil, 3, 5, nil, 9, 10)
assert(table.equals(box_call, lua_call))
box_call = box.func.args_type:call({1, 2, 3, 'string'})
lua_call = args_type(1, 2, 3, 'string')
assert(table.equals(box_call, lua_call))
box_call = box.func.args_type:call({nil, nil, 3})
lua_call = args_type(nil, nil, 3)
assert(table.equals(box_call, lua_call))
box.schema.func.drop('args_type')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment