Making globals readonly without fenv? #2057
FaultyPine
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
^ from luau.org
How does Roblox do this without calling lua_setfenv? Wouldn't you need to call that in order to replace the global table for a given script? If you do, doesn't that deoptimize the environment and is there a way to do this without that side effect? If not, how do you isolate scripts without manipulating the environment with fenv funcs?
Also, from some tests in a custom engine, I've found the follow lines of code to produce the following output, which is unexpected.
Printing out
testand breaking in a debugger and looking at the value of "test"... I saw it contained "HERE". Luau makes those builtin library tables read-only, so i'm confused how this is possible. I do a similar thing to those last few sentences from the link above, where I override each script's global table and it's __index to point to the global table, so maybe that has something to do with it?Does it have to do with https://luau.org/sandbox
And the features this refers to?
TLDR: Looking for some clarification on what globals are/aren't read-only in Luau by default, and how to best prevent globals from being accidentally modified.
Beta Was this translation helpful? Give feedback.
All reactions