Commit 14ddd71b authored by Pierre Chapuis's avatar Pierre Chapuis

avoid an error when calling ipairs() on packers

parent dc12b017
......@@ -60,7 +60,10 @@ local function checktype (caller, narg, arg, tname)
end
local packers = setmetatable({}, {
__index = function (t, k) error("pack '" .. k .. "' is unimplemented") end
__index = function (t, k)
-- return nil for k == 1 to avoid breaking ipairs()
if k ~= 1 then error("pack '" .. k .. "' is unimplemented") end
end
})
m.packers = packers
......
......@@ -43,7 +43,10 @@ local function checktype (caller, narg, arg, tname)
end
local packers = setmetatable({}, {
__index = function (t, k) error("pack '" .. k .. "' is unimplemented") end
__index = function (t, k)
-- return nil for k == 1 to avoid breaking ipairs()
if k ~= 1 then error("pack '" .. k .. "' is unimplemented") end
end
})
m.packers = packers
......
......@@ -2,7 +2,7 @@
require 'Test.More'
plan(23)
plan(24)
local mp = require 'MessagePack'
......@@ -114,6 +114,10 @@ error_like( function ()
lives_ok( function ()
mp.packers['fixext4']({}, 1, '1234')
end,
"fixext4" )
end,
"fixext4" )
lives_ok( function ()
for _ in ipairs(mp.packers) do end
end,
"cannot iterate packers" )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment