[Tarantool-patches] [PATCH v2 1/6] Fix luacheck warnings in src/lua/

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Apr 11 19:54:40 MSK 2020


Thanks for the patch!

> diff --git a/src/lua/swim.lua b/src/lua/swim.lua
> index 0859915c9..466e77ce4 100644
> --- a/src/lua/swim.lua
> +++ b/src/lua/swim.lua
> @@ -782,20 +782,20 @@ local swim_member_event_mt = {
>  --
>  -- Create a closure function for preprocessing raw SWIM member
>  -- event trigger parameters.
> --- @param s SWIM instance.
> +-- @param instance SWIM instance.

luacheck reported shadowing of 's' in the cycle below, so it is
enough to fix the cycle.

I fixed that in a separate commit. Squash it if you agree.

>  -- @param callback User functions to call.
>  -- @param ctx An optional parameter for @a callback passed as is.
>  -- @return A function to set as a trigger.
>  --
> -local function swim_on_member_event_new(s, callback, ctx)
> +local function swim_on_member_event_new(instance, callback, ctx)
>      -- Do not keep a hard reference to a SWIM instance. Otherwise
>      -- it is a cyclic reference, and both the instance and the
>      -- trigger will never be GC-ed.
> -    s = setmetatable({s}, {__mode = 'v'})
> +    instance = setmetatable({instance}, {__mode = 'v'})
>      return function(member_ptr, event_mask)
> -        local s = s[1]
> -        if s then
> -            local m = swim_wrap_member(s, member_ptr)
> +        local i = instance[1]
> +        if i then
> +            local m = swim_wrap_member(i, member_ptr)
>              local event = setmetatable({event_mask}, swim_member_event_mt)
>              return callback(m, event, ctx)
>          end

See diff below and in a separate commit on the branch.

====================
diff --git a/src/lua/swim.lua b/src/lua/swim.lua
index 466e77ce4..8e3b0ab13 100644
--- a/src/lua/swim.lua
+++ b/src/lua/swim.lua
@@ -782,20 +782,20 @@ local swim_member_event_mt = {
 --
 -- Create a closure function for preprocessing raw SWIM member
 -- event trigger parameters.
--- @param instance SWIM instance.
+-- @param s SWIM instance.
 -- @param callback User functions to call.
 -- @param ctx An optional parameter for @a callback passed as is.
 -- @return A function to set as a trigger.
 --
-local function swim_on_member_event_new(instance, callback, ctx)
+local function swim_on_member_event_new(s, callback, ctx)
     -- Do not keep a hard reference to a SWIM instance. Otherwise
     -- it is a cyclic reference, and both the instance and the
     -- trigger will never be GC-ed.
-    instance = setmetatable({instance}, {__mode = 'v'})
+    s = setmetatable({s}, {__mode = 'v'})
     return function(member_ptr, event_mask)
-        local i = instance[1]
-        if i then
-            local m = swim_wrap_member(i, member_ptr)
+        local si = s[1]
+        if si then
+            local m = swim_wrap_member(si, member_ptr)
             local event = setmetatable({event_mask}, swim_member_event_mt)
             return callback(m, event, ctx)
         end
diff --git a/src/lua/tap.lua b/src/lua/tap.lua
index 04497386e..094eb883f 100644
--- a/src/lua/tap.lua
+++ b/src/lua/tap.lua
@@ -53,7 +53,6 @@ local function ok(test, cond, message, extra)
     io.write(string.format("not ok - %s\n", message))
     extra = extra or {}
     if test.trace then
-        debug.getinfo(3, "Sl")
         extra.trace = traceback()
         extra.filename = extra.trace[#extra.trace].filename
         extra.line = extra.trace[#extra.trace].line


More information about the Tarantool-patches mailing list