Why does this code crash studio?

I was just messing around and wrote this in the command line
setfenv(function()a()end,setmetatable({},{__index=getfenv}))()

edit: it crashes for lots of different values of __index that also include setfenv, setmetatable, rawset, true, false and 1

setfenv(function()a()end,setmetatable({},{__index=1}))()

Thank you for reporting this, we’ll fix it. My guess is that our code assumes that a metatable’s __index is a table and doesn’t handle non-tables.

1 Like

__index is usually a function and it’s crashing for some functions.

Is it crashing for functions which don’t return a value?

These functions should cause an error anyway with the arguments that would be passed to them. There are some functions it doesn’t crash for, like getmetatable, rawget, pcall, print, but getfenv also returns a value.