Added specific error message on 'strict table' when table is empty
This commit is contained in:
parent
57ddbbf62f
commit
b85dc4694a
|
@ -146,6 +146,7 @@ return function (module_name)
|
|||
__index = function (t, k)
|
||||
local keys = {}
|
||||
for k in pairs(t) do keys[#keys+1] = k end
|
||||
if #keys then external_error(err_hdl, '', 'Attempting to index unknown key %s in an empty table.', k) end
|
||||
correct_error(err_hdl, '', 'Attempting to index unknown key %s, maybe you meant %s?', k, keys)
|
||||
end
|
||||
})
|
||||
|
|
|
@ -107,6 +107,11 @@ SUITE:addTest('Strict tables throw errors on unknown indices', function()
|
|||
bad_call(function() return t.hello end)
|
||||
end)
|
||||
|
||||
SUITE:addTest('Strict tables throw specific error on empty table', function()
|
||||
local t = error.strict_table {}
|
||||
bad_call(function() return t.hello end)
|
||||
end)
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user