Simpler code for 'traversetable'

Check the mode in a separate function (getmode), instead of using
comma expressions inside the 'if' condition.
This commit is contained in:
Roberto Ierusalimschy
2025-06-16 15:50:12 -03:00
parent 0cecf1ab6d
commit 8cd7ae7da0
2 changed files with 35 additions and 17 deletions

View File

@@ -288,6 +288,11 @@ x,y,z=nil
collectgarbage()
assert(next(a) == string.rep('$', 11))
do -- invalid mode
local a = setmetatable({}, {__mode = 34})
collectgarbage()
end
-- 'bug' in 5.1
a = {}