Prevent used globals from being counted multiple times in :ss #1830
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After #1486 introduced the global import optimization update in Loadstring, global variables are being counted towards the 200 local variable limit multiple times. This causes the limit to be depleted very quickly in some cases. The change in #1587 addressed a formatting error in LuaY that concealed this issue in LuaX, but didn't fix the root cause of the error, which is what this change should do.
Me and @ServerNoob found that if you only localize used globals once, the number of local variables created comes down significantly. I'm not sure if this is an actual issue or intentional behavior for optimization purposes, but since the exact same script that worked before #1486 is now causing errors (and also works in a normal Luau environment on Roblox, like the Developer Console), I think this is a bug.
Proof of functionality: https://www.youtube.com/watch?v=1IwQZPIvMvw
In the video, I imported Adonis into a new baseplate, and modified the config + LuaY to print local vars. Then, I ran the same testing script on:
Steps script followed in pof: https://github.com/user-attachments/files/18431880/Steps.txt