From 05828bd840a57fb40804b2eb0292218150da7cd0 Mon Sep 17 00:00:00 2001 From: rxi Date: Wed, 5 Mar 2014 19:11:14 +0000 Subject: [PATCH] Fixed module's table not updating in lume.hotswap() Changed the returned values from pcall() in lume.hotswap() to be handled correctly -- the second return value being the wrapped-function's first return value. This bug would effect hotswapped modules which used the modern approach of returning a table rather than creating globals. --- lume.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lume.lua b/lume.lua index 61ab0c2..c3cf660 100644 --- a/lume.lua +++ b/lume.lua @@ -266,12 +266,13 @@ function lume.hotswap(modname) if type(v) == "table" then update(old[k], v) else old[k] = v end end end - local oldmod = pcall(require, modname) or nil local err = nil local function onerror(e) for k, v in pairs(_G) do _G[k] = oldglobal[k] end err = lume.trim(e) end + local ok, oldmod = pcall(require, modname) + oldmod = ok and oldmod or nil xpcall(function() package.loaded[modname] = nil local newmod = require(modname)