If I have only this:
function a(arg)
if arg == 1 then b(1) end
end
function b(arg)
if arg == 2 then a(2) end
end
… no warnings are shown.
But if I enclose these functions inside another function:
local function main()
function a(arg)
if arg == 1 then b(1) end
end
function b(arg)
if arg == 2 then a(2) end
end
end
… I get:
W003: (2,11) Global ‘a’ is only used in the enclosing function ‘main’; consider changing it to local
W003: (3,20) Global ‘b’ is only used in the enclosing function ‘main’; consider changing it to local
If I change only local function a
I get:
W003: (3,20) Global ‘b’ is only used in the enclosing function ‘main’; consider changing it to local
If I change both to local
I get:
W001: (3,20) Unknown global ‘b’
How to solve this puzzle?