Hi! I’m not sure if this is the right category, but -
Normally, in Lua, the two main ways of declaring functions,
function fn() -- Both local & global
end
f = function() -- both local & global
end
are syntactic sugar.
Because Luau is derived from Lua 5.1, in which this rule still applied, these should function the same way - whether it be debug.info(1, “n”), calling the function, and everything in between.
However, despite this:
Luau, at least Roblox’s branch of Luau, does not treat these two methods of declaring functions the same, particularly in debug.info().
local function f()
print(debug.info(1, "n"))
end
function g()
print(debug.info(1, "n"))
end
local lf = function()
print(debug.info(1, "n"))
end
lg = function()
print(debug.info(1, "n"))
end
f() -- 'f'
g() -- 'g'
lf() -- '' (nil)
lg() -- '' (nil)
Output:
00:29:04.952 f - Server - Script:2
00:29:04.952 g - Server - Script:6
00:29:04.952 - Server - Script:10
00:29:04.952 - Server - Script:14
Expected behavior
However, if you look at Lua, in which I will just use an online compiler for ease of use (it remains functionally the same):
local function f()
print(debug.getinfo(1, "n").name) -- debug.getinfo() *should* work the same as debug.info in practice
end
function g()
print(debug.getinfo(1, "n").name)
end
local lf = function()
print(debug.getinfo(1, "n").name)
end
lg = function()
print(debug.getinfo(1, "n").name)
end
f() -- 'f'
g() -- 'g'
lf() -- "lf"
lg() -- "lg"
If everything was working correctly, or at least in the same way Lua works, it should be printing these.
If any further information is needed, it will be provided if possible. Also happy to clarify anything because this was written at 01:17 at night, so my writing may not be the most clear.
A private message is associated with this bug report

