Skip to content

Commit

Permalink
loader args: provide consistent behavior across Lua versions
Browse files Browse the repository at this point in the history
This implements a compromise solution that allows Teal modules
to always get both arguments, even in Lua 5.1 based systems
(this should be harmless for modules which don't expect a second
argument there), without hardcoding `loader_data`, just in case
the user is on an environment that runs a patched `require` for
debug reasons or something.
  • Loading branch information
hishamhm committed Sep 5, 2023
1 parent c01dbf9 commit 0dafaf6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -10825,6 +10825,9 @@ local function tl_package_loader(module_name: string): any, any
local chunk, err = load(code, "@" .. found_filename, "t")
if chunk then
return function(modname: string, loader_data: string): any
if loader_data == nil then
loader_data = found_filename
end
local ret = chunk(modname, loader_data)
package.loaded[module_name] = ret
return ret
Expand Down

0 comments on commit 0dafaf6

Please sign in to comment.