From 0dafaf6bd158c4db4d5a7b4f0e36202938ee3cec Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Tue, 5 Sep 2023 12:03:08 -0300 Subject: [PATCH] loader args: provide consistent behavior across Lua versions 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. --- tl.tl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tl.tl b/tl.tl index 6068f3b5c..2e79e1fd8 100644 --- a/tl.tl +++ b/tl.tl @@ -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