commit d4fa8ba: [Fix] Deduct type of a table methods
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Nov 13 11:35:09 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-11-13 11:29:41 +0000
URL: https://github.com/rspamd/rspamd/commit/d4fa8bac0ab2e98168350c00a3053612d736d40d (HEAD -> master)
[Fix] Deduct type of a table methods
---
lualib/lua_selectors/init.lua | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/lualib/lua_selectors/init.lua b/lualib/lua_selectors/init.lua
index 8de79f767..54d42f242 100644
--- a/lualib/lua_selectors/init.lua
+++ b/lualib/lua_selectors/init.lua
@@ -338,20 +338,24 @@ exports.parse_selector = function(cfg, str)
},
map_type = 'string',
process = function(inp, t, args)
+ local ret
if t == 'table' then
- return inp[method_name],'string'
+ -- Plain table field
+ ret = inp[method_name]
else
-- We call method unpacking arguments and dropping all but the first result returned
- local ret = (inp[method_name](inp, unpack_function(args or E)))
- local ret_type = type(ret)
- -- Now apply types heuristic
- if ret_type == 'string' then
- return ret,'string'
- elseif ret_type == 'table' then
- return ret,'string_list'
- else
- return implicit_tostring(ret_type, ret)
- end
+ ret = (inp[method_name](inp, unpack_function(args or E)))
+ end
+
+ local ret_type = type(ret)
+ -- Now apply types heuristic
+ if ret_type == 'string' then
+ return ret,'string'
+ elseif ret_type == 'table' then
+ -- TODO: we need to ensure that 1) table is numeric 2) table has merely strings
+ return ret,'string_list'
+ else
+ return implicit_tostring(ret_type, ret)
end
end,
}
More information about the Commits
mailing list