lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi All,

I recently noticed that I don't get expected results from activelines table when I use it on the function returned by load/loadstring. The following fragment shows the difference:

local function a()
  print("a")
  print("b")
end

local b = (loadstring or load)("function a()\n  print(1)\n  print(2)\nend")

for i in pairs(debug.getinfo(a, "L").activelines) do
  print("case a", i)
end
for i in pairs(debug.getinfo(b, "L").activelines) do
  print("case b", i)
end

For case a, I get 2, 3, 4 as expected, but for case b I get 1 and 4. I get exactly the same result with Lua 5.1-5.3 and LuaJIT, which tells me that there is a reason for this behavior. How do I get line numbers the execution will be stopped on without executing the fragment?

Paul.