Lua: Reject setting metatable to a nil value

pull/1232/head
Zef Hemel 2025-02-06 08:36:28 +01:00
parent e44b2776df
commit 4f707e498c
1 changed files with 4 additions and 1 deletions

View File

@ -124,7 +124,10 @@ const xpcallFunction = new LuaBuiltinFunction(
);
const setmetatableFunction = new LuaBuiltinFunction(
(_sf, table: LuaTable, metatable: LuaTable) => {
(sf, table: LuaTable, metatable: LuaTable) => {
if (!metatable) {
throw new LuaRuntimeError("metatable cannot be set to nil", sf);
}
table.metatable = metatable;
return table;
},