Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lua_*upvalue() when upvalue names aren't in debug info #787

Merged
merged 2 commits into from
Jan 18, 2023
Merged

Fix lua_*upvalue() when upvalue names aren't in debug info #787

merged 2 commits into from
Jan 18, 2023

Conversation

HaroldCindy
Copy link
Contributor

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.

@matthargett
Copy link

Add a unit test that only passes with the code change?

@HaroldCindy
Copy link
Contributor Author

Good call, added a test that compiles a script with no debug info, then yields in the middle of executing a closure to examine its upvalues.

@vegorov-rbx vegorov-rbx merged commit 729bc44 into luau-lang:master Jan 18, 2023
@HaroldCindy HaroldCindy deleted the fix_getupvalue_no_names branch February 3, 2024 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants