diff options
| -rw-r--r-- | xmake/core/sandbox/modules/ipairs.lua | 7 | ||||
| -rw-r--r-- | xmake/core/sandbox/modules/pairs.lua | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/xmake/core/sandbox/modules/ipairs.lua b/xmake/core/sandbox/modules/ipairs.lua index 14616cea3..6df5d9e93 100644 --- a/xmake/core/sandbox/modules/ipairs.lua +++ b/xmake/core/sandbox/modules/ipairs.lua @@ -25,13 +25,14 @@ local table = require("base/table") function sandbox_ipairs(t) -- exists the custom ipairs? - if type(t) == "table" and t.ipairs then + local is_table = type(t) == "table" + if is_table and t.ipairs then return t:ipairs() end -- wrap table and return iterator - if t == nil then - t = {} + if not is_table then + t = t ~= nil and {t} or {} end return function (t, i) i = i + 1 diff --git a/xmake/core/sandbox/modules/pairs.lua b/xmake/core/sandbox/modules/pairs.lua index a1a5a5588..9494cd3b5 100644 --- a/xmake/core/sandbox/modules/pairs.lua +++ b/xmake/core/sandbox/modules/pairs.lua @@ -25,13 +25,14 @@ local table = require("base/table") function sandbox_pairs(t) -- exists the custom ipairs? - if type(t) == "table" and t.pairs then + local is_table = type(t) == "table" + if is_table and t.pairs then return t:pairs() end -- wrap table and return iterator - if t == nil then - t = {} + if not is_table then + t = t ~= nil and {t} or {} end return function (t, i) return next(t, i) |
