fix(cache): reload file if compiled code is incompatible. Fixes #225

This commit is contained in:
Folke Lemaitre 2022-12-29 08:25:24 +01:00
parent 4e3a973f85
commit b8c5ab5dae
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 4 additions and 1 deletions

View File

@ -158,7 +158,10 @@ function M.load(modkey, modpath)
entry.used = os.time()
if M.eq(entry.hash, hash) then
-- found in cache and up to date
return loadstring(entry.chunk --[[@as string]], "@" .. entry.modpath)
local chunk, err = loadstring(entry.chunk --[[@as string]], "@" .. entry.modpath)
if not (err and err:find("cannot load incompatible bytecode", 1, true)) then
return chunk, err
end
end
else
entry = { hash = hash, modpath = modpath, used = os.time() }