mirror of
https://github.com/luau-lang/luau.git
synced 2024-12-12 21:10:37 +00:00
729bc44729
`lua_getupvalue()` and `lua_setupvalue()` don't behave as expected when working with Lua closure whose `Proto` has no debug info. The code currently uses `sizeupvalues` to do bounds checking of upvalue indices, but that's the size of the upvalue _names_ array. It will always be `0` if the `Proto` doesn't have debug info. This uses `nups` instead, and just returns `""` as the upvalue name if we don't have one, same as for C closures. Co-authored-by: Harold Cindy <HaroldCindy@users.noreply.github.com>
13 lines
396 B
Lua
13 lines
396 B
Lua
-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
-- This tests that the lua_*upval() APIs work correctly even with debug info disabled
|
|
local foo = 5
|
|
function clo_test()
|
|
-- so `foo` gets captured as an upval
|
|
print(foo)
|
|
-- yield so we can look at clo_test's upvalues
|
|
coroutine.yield()
|
|
end
|
|
|
|
clo_test()
|
|
|
|
return 'OK'
|