Closed jadawil closed 2 years ago
print( file2.get_src() )
Is there a typo in your example? I assume you mean something like:
-- file2.lua
local file1 = require("file1")
print(file1.get_src())
instead?
In any case, I couldn't reproduce it here. With your file1.lua and the file2.lua from this comment, I get:
hisham@proxy master ~/projects/tl] tl run file2.lua
@file2.lua
hisham@proxy master ~/projects/tl] lua file2.lua
@file2.lua
hisham@proxy master ~/projects/tl] luajit file2.lua
@file2.lua
How exactly are you running the examples?
Yep sorry, fixed.
The issue is when the teal loader is included so something like this:
-- main.lua
local tl = require("tl")
tl.loader()
local file1 = require("file1")
print( file1.get_src() )
luajit main.lua
The issue looks to be because this loader uses "loadstring" to load the files, which doesn't work well with the debug lib https://www.lua.org/pil/23.1.html
@jadawil Ahh, that makes sense, thank you! I'm actually using load
in the loader, and I was just passing the module name as the chunkname. It's an easy change to pass it "@" .. filename
instead to make it behave like the "native" loading of Lua modules by require!
Seems like teal is breaking something in debug getinfo
Example file1.lua
file2.lua
Outputs With Teal -> file2 Without Teal -> @./src/file2.lua
If file2.lua called debug.getinfo( 1, "S" ).source with teal it gets the correct full path.
Environment Teal: 0.13.2 Lua: tarantool 2.8.2