-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix lua_*upvalue() when upvalue names aren't in debug info (#787)
`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 <[email protected]>
- Loading branch information
1 parent
a5c6a38
commit 729bc44
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- 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' |